New route method on every controller

136 views
Skip to first unread message

javinto

unread,
Feb 21, 2013, 9:48:27 AM2/21/13
to rubyonra...@googlegroups.com
Hi

In my routes I have a

match ":controller/help", :action=>'help'     (Rake routes shows:  /:controller/help(.:format)            :controller#help)

This will add a help action on every controller, including namespaced controllers.

As Rails 4 will not be supporting 'match' anymore I'm converting these routes to get, put, etc. No sweat, except for this route:

get ':controller/help'        (Rake routes shows: GET    /:controller/help(.:format)                                                                  :controller#help)

This route does not work on namespaced controllers, like:

namespace :admin do
    myController
end

I tried declaring:

namespace :admin do
    get ':controller/help'
    myController
end

But rake routes is telling me: :controller segment is not allowed within a namespace block

Is there another solution to this?

Pardeep Dhingra

unread,
Feb 28, 2013, 6:10:23 AM2/28/13
to rubyonra...@googlegroups.com
I think you need

get ':controller/help'
and

get ':namespace/:controller/help'

--
Posted via http://www.ruby-forum.com/.

Jan Verhoek

unread,
Feb 28, 2013, 6:21:53 AM2/28/13
to rubyonra...@googlegroups.com
Worth trying! But unfortunately not working neither. But thanks!
> --
> You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/XSEIpeRHC68/unsubscribe?hl=en-US.
> To unsubscribe from this group and all its topics, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages