Questions tagged [respond-with]

51 questions
1
vote
0 answers

Issues when downloading a file with a service worker and ReadableStream

I did some testing and I have some problems with streaming a file meant to be downloaded (with Content-Disposition header set to attachment in the response). The following behaviour is common to both Firefox et Chrome and I'll call 'browser' the…
Khivar
  • 61
  • 4
1
vote
1 answer

override to_xml to limit fields returned

using ruby 1.9.2 and rails 3, i would like to limit the fields returned when a record is accessed as json or xml (the only two formats allowed). this very useful post introduced me to respond_with and i found somewhere online that a nice way to…
jay
  • 602
  • 5
  • 14
1
vote
2 answers

wrong location in respond_with multiple object

I have to pass 2 objects to show so I tried to put this respond_with(@ticketnfr, @ticket) but it goes to ticket controller view, when I tried with only one object respond_with(@ticketnfr) it goes correctly to ticketnfr/show, but I miss the ticket…
alfitra
  • 27
  • 7
1
vote
3 answers

ActionController::UnknownFormat in Devise::RegistrationsController#create due to CRUD implementation of Users

Intention I have created a User model as the Devise documentation indicates. Later on, I have scaffolded a controller and views so to have an index and a visual interface to handle my Users. Problem After visiting edit_user_path, I submit a new user…
1
vote
3 answers

Alert flash message not working with respond_with

I'm using responders gem in my Rails 4.2 application. I got a pretty complex situation, where in a Organization model edit view I got a form for a OrganizationUser with one input. Adding user to organization invokes a create action in a…
Dawid
  • 644
  • 1
  • 14
  • 30
1
vote
1 answer

Rails 3.2.16 JSON API behavior for respond_with while updating object

A bit of a conundrum around using JSON for updating resources: If I use "POST" against /resource/:id - I get an undefined route If I use "PUT" against a /resource/:id - I do get to the right method, but respond_with seems to return an empty content…
aabes
  • 208
  • 1
  • 12
1
vote
1 answer

Rails: respond_with not working properly during create action

Here is my create method in my controller (old way): def create @athlete = Athlete.find(params[:video][:athlete_id]) @video = Video.new(params[:video]) if @athlete.can_add_another_video? && @video.save flash[:notice] =…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
1
vote
1 answer

set a rails controller's response type to xml

i'm quite new to rails. i'm trying to set a rails controller's response type to xml, but not having much luck. i could certainly afford to better understand how respond_to and respond_with work. here's what my controller looks like: class…
dougiebuckets
  • 2,383
  • 3
  • 27
  • 37
1
vote
3 answers

Using JQuery and Rails to generate preview of link

what I am interested in doing is implementing a basic version of a link preview tool in JQuery and RoR (similar to what Facebook has). A user types a url in an input field. A jquery function monitors what is typed (using keyup), and when a valid url…
amillet89
  • 75
  • 1
  • 1
  • 6
1
vote
2 answers

Respond_with templates and status codes

There are some instances where I need to both have a template and return error codes when using respond_with in Rails 3. I have a before filter that is as follows: def ensure_premium respond_with("Must be a premium user!", status: 401, location:…
Robert Rouse
  • 4,801
  • 1
  • 19
  • 19
0
votes
1 answer

(Missing) Steps to support iPhone in new Rails 3 app

What step am I missing? The view being returned to my iPhone is coming from application.html.erb and index.html.erb Step 1: In config/initializers/mime_types.rb uncomment the declaration line for the iPhone: Mime::Type.register_alias "text/html",…
tobinjim
  • 1,862
  • 2
  • 19
  • 31
0
votes
1 answer

Getting "undefined method `flash`" for my controllers after updating Rails from 4.1 to 5.2 and added the responders gem

I'm in the process of updating rails from 4.1 to 5.2 I added the responders gem so respond_with is present. My ApplicationController now looks like this: class ApplicationController < ActionController::API self.responder = ApplicationResponder …
0
votes
1 answer

Respond with script from a Rails API app with limited middleware (config.api_only = true)?

I have a Rails 5 app build as an api app. So by default it only responds with json. But for one specific request I need the app to respond with a script. In a regular Rails app I would simply put my script in a js.erb file. This won't work here. If…
0
votes
2 answers

Rails3 and Respond_with problem

I have an application, on which I have two user interfaces. The first one is for normal users and the second one is for iphone users. Everything was working fine until i refactored my code within controller to use the respond_with declarative…
Arkan
  • 6,196
  • 3
  • 38
  • 54
0
votes
1 answer

Rails - Intercept respond_with

I am using this 3rd party controller: class LibController def update # 29 lines of code respond_with resource end end I want to do something other than the respond_with at the end. But I don't want to just…
Matt
  • 5,461
  • 7
  • 36
  • 43