Rails routing for render xml gives 404
-
26-09-2019 - |
Question
I'm facing a problem I don't really understand.
This is my controller
def index
@resources = Resource.all(:limit => 10)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @resources }
end
end
When i try to access the html page, everything works fine, but when i hit the .xml format, then i got this nasty problem from the log:
Parameters: {"name"=>["api", "resources.xml"]}
Resulting in a consequential 404 page. The page was created with a scaffold, and the routing rule
map.connect ':controller/:action/:id.:format'
exists, and also if i put it on the top, it doesn't work.
What can i do?
Solution
I was having the same issue in my hosted server. After reviewing the mongrel.log I realized that the problem was with the dispatcher.
Error calling Dispatcher.dispatch #
Doing some research I found out this is a mongrel bug...https://rails.lighthouseapp.com/projects/8994/tickets/4690-mongrel-doesnt-work-with-rails-238
And the solution, provided in the same link is as follows
create a config/environment/mongrel.rb with the following
Hope it helps you as well!