Questions tagged [respond-to]

112 questions
2
votes
1 answer

Can I do a wildcard with 'responds-to format' in Rails3?

Consider the following code: respond_to do |format| format.js { render :layout => false } format.xml { head :ok } end Now I know you can specify a whole bunch of formats, but is there a way to specify all other formats (in this case other than…
Ash
  • 24,276
  • 34
  • 107
  • 152
2
votes
3 answers

How to respond to ajax call in Rails

I know there are many questions about that already on stackoverflow but none of them has been useful for me. Here is my ajax code: function update_schedule($task){ var taskId = $task.data("taskId"), startHour, endHour, userId =…
Mark
  • 275
  • 1
  • 4
  • 16
2
votes
1 answer

ReporteController#opcionales is missing a template for this request format and variant. request.formats: ["application/pdf"] request.variant: []

"\nrequest.variant: #{request.variant.inspect}" raise ActionController::UnknownFormat, message elsif interactive_browser_request? message = "#{self.class.name}\##{action_name} is missing a template " \ "for this request format and…
Juan Velasquez
  • 385
  • 4
  • 15
2
votes
2 answers

Getting status: code on ajax response in a .js.erb file on Rails

I've just started to play with Rails applications and I'm trying to use Ajax on a form, but I don't know how to catch the status code inside a js.erb file. I'm following this tutorial:…
2
votes
3 answers

form_tag + file_field_tag causes the controller to respond to format.html?

my routes.rb: post 'home/review' my home_conrtoller.rb: def review @review = Review.new(review_params) @review.image = params[:review][:image] if @review.save respond_to do |format| format.js { render 'review', locals:…
deni5n
  • 97
  • 1
  • 10
2
votes
5 answers

json request return html in rails

I'm currently trying to make a Ajax script to communicate with an Rails server on my localhost (for now). The problem is that I specify in my $.ajax request that I want the format in 'json' but rails returns a 'html'…
leo
  • 19
  • 1
  • 5
2
votes
1 answer

Explain the difference between ActionController#respond_to and ActionController::respond_to

I've read the documentation, and it confuses me every time, just because it doesn't answer some basic things. I realize the main purpose of the class method ::respond_to (which is normally used at the top of the controller) is for use in…
mltsy
  • 6,598
  • 3
  • 38
  • 51
2
votes
0 answers

Rails 4 Devise Sessions Controller Unknown Format

I'm encountering this error : ActionController::UnknownFormat (ActionController::UnknownFormat): Each time i'm posting to Rails 4 Devise Sessions Api Controller. Here is the gist as well as logs, can anyone please help me with this…
Sooriah Joel
  • 111
  • 2
  • 6
2
votes
1 answer

JRuby: command pattern in Java with Ruby block: why does it work?

I am learning how to integrate Java library with Ruby code and come to the following question. I have a command pattern implemented in Java, as follows: public interface Command { public String execute(String param); } public class CommandRunner…
wrzasa
  • 1,113
  • 10
  • 20
2
votes
2 answers

rails respond_to does not stop code from executing further

I have a couple action inside my cart_controller. I have 2 views inside /carts: payment.html.erb and pay.html.erb def pay success = #do something that returns true or false if success respond_to do |format| format.html {…
manni
  • 717
  • 1
  • 9
  • 25
1
vote
2 answers

Object.respond_to? stuck in infinite loop

I'm building a Rails 3 gem that essentially modifies the records returned from an ActiveRecord query. One of the things I'm doing is overriding the method_missing and respond_to? methods, but it seems that my respond_to? definition is resulting in…
Matt Huggins
  • 81,398
  • 36
  • 149
  • 218
1
vote
1 answer

Rails: respond_with RESTful controller template after non-RESTful action

Getting "Template is missing - Missing template ballots/submission" error when trying to add a "publish" action to an otherwise RESTful controller. Clearly it is looking for a submission.html.haml view, which doesn't exist (and shouldn't). class…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
1
vote
3 answers

How to convert this respond_to options to use Rails 3 version?

respond_to do |format| if @user.save format.js { render :nothing => true, :status => :ok, :location => @user } else format.js { render :json => @user.errors, :status => :unprocessable_entity } end end All options I've tried (like…
Jacob
  • 6,317
  • 10
  • 40
  • 58
1
vote
1 answer

ActionController::UnknownFormat in Rails 5

I have some product list where the user can add/remove items from their product list. I would like the mentioned iteration to be done via ajax with format.js This is part of my input view where do i have the buttons to add/remove user items from…
Samuel D.
  • 199
  • 10
1
vote
1 answer

Why is this controller returning an html, causing respond_to to fail?

I'm following a course where we are trying to render a partial through a respond_to. I have been following it strictly, and I'm very confused about why my project is now showing an error while the instructor's project up to this point is running…
Imnotanerd
  • 1,167
  • 2
  • 14
  • 30