I wonder is anyone can give me a pointer in the right direction.
we''ve recently upgraded our app to Rails 3. We previous had a
situation where it was necessary to allow our create action on a
resourceful controller to be accessible in the following way
GET   /resources/create  -> ResourcesController#create
POST /resources            -> ResourcesController
This would do the job
resources :resources, :collection { :create => :get, :authorize => :get }
and we''d get the following router helper to boot
create_resources_path/url
In Rails 3 this has changed however and now I''m finding it extremely
difficult to replicate
resources :resources do
  collection do
    get :create
    get :authorize
  end
end
This would be the most obvious way I would think to solve this.
but alas this route doesn''t exist
create_resources GET /resources/create -> ResourcesController#create
however this does, so the create action is being treated differently
and so needs some other modification to make it work as I would like
it to.
authorize_resources GET /resources/authorize -> ResourcesController#authorize
The following does part of the job, but renders
resources :resources do
  collection do
    get :create, :as => ''create''
    get :authorize
  end
end
create_resources GET /resources -> ResourcesController#create
This of course then overrides the index route for this controller
resources GET /resources -> ResourcesController#index
This also seems to have no effect?!?
resources :resources, :path_names => {:create =>
''create'' } do
  collection do
    get :create, :as => ''create''
    get :authorize
  end
end
Can anyone help?
-- 
Rob Lacey
contact-+WAvBcCRUVA@public.gmane.org
http://www.robl.me
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
You''re having a hard time with "create" because it''s one of the default actions (show, create, update, destroy, new, edit). There''s some hard coding in Rails that''s interfering with what you''re trying to do. In this case, if the action is "create", it excludes the action from the path. Overriding the default actions generally isn''t a good idea. That being said, you can force rails to do what you want by forcing the path option: get :create, :as => :create, :path => :create -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Tim, that''s exactly what I was looking for. I don''t disagree that messing too much with these defaults is something I''d want to do often and without reason. Effectively this is just another route to an existing action, in the same way that get :authorize. Had this not worked so easily in Rails 2 I might have opted for resources/generate and this wouldn''t have been an issue :) Cheers RobL On 11 January 2011 14:05, Tim Shaffer <timshaffer-BUHhN+a2lJ4@public.gmane.org> wrote:> You''re having a hard time with "create" because it''s one of the default > actions (show, create, update, destroy, new, edit). There''s some hard coding > in Rails that''s interfering with what you''re trying to do. In this case, if > the action is "create", it excludes the action from the path. > > Overriding the default actions generally isn''t a good idea. That being said, > you can force rails to do what you want by forcing the path option: > > get :create, :as => :create, :path => :create > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Rob Lacey contact-+WAvBcCRUVA@public.gmane.org http://www.robl.me -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.