Actioncontroller::Unknownformat

ActionController::UnknownFormat

Update the create action as below:

def create
...
respond_to do |format|
if @reservation.save
format.html do
redirect_to '/'
end
format.json { render json: @reservation.to_json }
else
format.html { render 'new'} ## Specify the format in which you are rendering "new" page
format.json { render json: @reservation.errors } ## You might want to specify a json format as well
end
end
end

You are using respond_to method but anot specifying the format in which a new page is rendered. Hence, the error ActionController::UnknownFormat .

ActionController::UnknownFormat in StocksController#search

Shouldn't you target #results instead of #result like

$('#results').html("<%=j (render 'users/result.html')%>")

Rails ActionController::UnknownFormat error with respond_to

For one, you're still specifying instance variables after your implicit call to render (in the respond_to block). Those instance variable declarations should be above any rendering.

Also, I've seen this happen in some browsers. You can get around it by declaring a dummy render block for the html type, so something like:

respond_to do |format|
format.html { render(:text => "not implemented") }
format.js
end

The html format block will likely never get called, but its declared nonetheless.

ActionController::UnknownFormat in Controller ( #index)

Well, after going around testing a wide range of ideas, I came back to my original thought and it worked perfectly. I don't know what went wrong the first time but now it is perfect.



Related Topics



Leave a reply



Submit