In beta4 I could do this: resources :sections do get :new, :on=>:member end But not with RC If I change "new" to be something else, it will work So it seems that "new" is now treated like a reserved word of sorts? I really need to share the new method between "sections/new" and "sections/1/new" because my structure is a tree, so it makes sense to re-use Example /section/1/new/ is so much cleaner (and dry) compared to /section/new/?parent=1 or /section/1/new_child Anyone have an opinion or suggestion? cheers! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Just tried my project from scratch and generated using rails RC, rather than just changing the version in the Gemfile. Didn''t work, but was worth testing :) If anyone has an idea, or a thought of why this change was made, would be good to hear cheers :) On Aug 2, 6:56 pm, Ned <rails.n...@gmail.com> wrote:> In beta4 I could do this: > > resources :sections do > get :new, :on=>:member > end > > But not with RC > > If I change "new" to be something else, it will work > > So it seems that "new" is now treated like a reserved word of sorts? > > I really need to share the new method between "sections/new" and > "sections/1/new" because my structure is a tree, so it makes sense to > re-use > > Example > > /section/1/new/ > > is so much cleaner (and dry) compared to > > /section/new/?parent=1 > or > /section/1/new_child > > Anyone have an opinion or suggestion? > > cheers!-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Santiago Pastorino
2010-Aug-13 23:24 UTC
Re: Re: Routing error/difference between RC and Beta4
Did you open an issue for this? if not would you mind to do it so it can be discussed there?. Thanks. On Wed, Aug 4, 2010 at 10:15 AM, Ned <rails.nerd@gmail.com> wrote:> > Just tried my project from scratch and generated using rails RC, > rather than just changing the version in the Gemfile. > > Didn''t work, but was worth testing :) > > If anyone has an idea, or a thought of why this change was made, would > be good to hear > > cheers :) > > > > On Aug 2, 6:56 pm, Ned <rails.n...@gmail.com> wrote: >> In beta4 I could do this: >> >> resources :sections do >> get :new, :on=>:member >> end >> >> But not with RC >> >> If I change "new" to be something else, it will work >> >> So it seems that "new" is now treated like a reserved word of sorts? >> >> I really need to share the new method between "sections/new" and >> "sections/1/new" because my structure is a tree, so it makes sense to >> re-use >> >> Example >> >> /section/1/new/ >> >> is so much cleaner (and dry) compared to >> >> /section/new/?parent=1 >> or >> /section/1/new_child >> >> Anyone have an opinion or suggestion? >> >> cheers! > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Symbols are reserved in the Rails 3 Router DSL (they are used internally). Consequently, we do not expose `get :new` as public API, so we don''t have tests for it causing its behavior change between releases due to internal needs. Bottom line is: you should always use strings. :) On Aug 13, 8:24 pm, Santiago Pastorino <santi...@wyeworks.com> wrote:> Did you open an issue for this? if not would you mind to do it so it > can be discussed there?. > Thanks. > > > > On Wed, Aug 4, 2010 at 10:15 AM, Ned <rails.n...@gmail.com> wrote: > > > Just tried my project from scratch and generated using rails RC, > > rather than just changing the version in the Gemfile. > > > Didn''t work, but was worth testing :) > > > If anyone has an idea, or a thought of why this change was made, would > > be good to hear > > > cheers :) > > > On Aug 2, 6:56 pm, Ned <rails.n...@gmail.com> wrote: > >> In beta4 I could do this: > > >> resources :sections do > >> get :new, :on=>:member > >> end > > >> But not with RC > > >> If I change "new" to be something else, it will work > > >> So it seems that "new" is now treated like a reserved word of sorts? > > >> I really need to share the new method between "sections/new" and > >> "sections/1/new" because my structure is a tree, so it makes sense to > >> re-use > > >> Example > > >> /section/1/new/ > > >> is so much cleaner (and dry) compared to > > >> /section/new/?parent=1 > >> or > >> /section/1/new_child > > >> Anyone have an opinion or suggestion? > > >> cheers! > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > > To post to this group, send email to rubyonrails-core@googlegroups.com. > > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-core?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On 4 Aug 2010, at 14:15, Ned wrote:> If anyone has an idea, or a thought of why this change was made, would > be good to hearIt was done as part of some changes to add back support for custom new actions e.g. /posts/new/preview. To support this we added new scope to resources to match member and collection scopes. So whereas before ''new'' would be added to the path scope, in RC it doesn''t because new_scope has already added new to the path. You can specify your routes as follows to get the effect you need: resources :sections, :id => /.+/ do get :new, :path => ''new'', :on => :member end However you''ll still need to address the create, edit and update actions plus you''ll need to override the :id constraint which doesn''t allow slashes. Also the show action comes before the edit action so the greedy regexp needed for :id will match the edit url. You would be better off manually specifying each of the routes individually - it''ll be easier than trying to bend resources to what you want: scope(''sections'', :controller => ''sections'', :id => /.+/) do get ''/(:id)/new'' => :new, :as => :new_section get ''/:id/edit'' => :edit, :as => :edit_section get ''/:id'' => :show, :as => :section put ''/:id'' => :update, :as => :section delete ''/:id'' => :destroy, :as => :section get ''/'' => :index, :as => :sections post ''/(:id)'' => :create, :as => :sections end This set of routes should do what you need. Andrew -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.