Non-standard Rails3 controller not routed: works in Rails2

I am using Rails 2.3.8 for the project I was working on, but reconfigured the project to Rails 3.0.3. After fixing the basic errors, I had a problem with a custom controller method.

In gallery_controller, I had my own method called "extract". On rails 2.3.8, this worked fine, with no additional configuration. I could go to / galleries / extract /: id and do what I wanted.

Now this code breaks the application when I try to create a link to it with the source code in the form:

<%= link_to "Add photos to gallery from: ",
        :action => 'extract', :id => @gallery.id %>

and the error I get when I try to go to a page with this code:

No route matches {:action=>"extract", :controller=>"galleries", :id=>2}

After looking at route.rb, I came to the conclusion that this fails because

match ':controller(/:action(/:id(.:format)))'

It does not turn on and is actually not recommended.

| grep 'extract' .

, ?

+3
1

. : RESTful. , :

resources :gallery do
  get 'extract', :on => :member
end
+4

Source: https://habr.com/ru/post/1780739/


All Articles