Ajax routes in Rails 3
In my Rails 2.3 application, the following routes were working properly
map.ajax 'ajax', :controller => 'widgetresponse_controller' , :action => 'getWidgetJson'
When I migrated to Rails 3,
I tried a number of new routes, to get this working but none of them worked.1.
match 'ajax' => 'widgetresponse#getWidgetJson', :as =>开发者_如何学JAVA; :ajax
2.
match 'ajax' => 'widgetresponse_controller#getWidgetJson', :as => :ajax
3.
get 'widgetresponse/getWidgetJson', :as => :ajax
4.
get 'widgetresponse/getWidgetJson'
Its a very basic question to ask, but I don't know what I am doing wrong.
You could try this:
match "/widgetresponse/getWidgetJson/:id" => "widgetresponse#getWidgetJson"
One thing that may have happened before is that things were falling through to the default route which was removed in Ruby on Rails 3 (good idea).
I found this guide:
http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/
really helpful with lot of yummy new rails 3 options.
精彩评论