There seems to be a small bug with has_one relationships and resource in the routes. Example: where beta has_one alpha In routes: resource alpha In view: form_for @alpha --> automatic link is alpah_path(id) and not alpha_path and in this case since there is no id in the route, the id takes the place of the format param -> /alpha.1 Thanks! Mike -- 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.
There have been a lot discussion about this a while ago. However, we couldn''t find the way to determine the correct route to use when you have a singular resource, so it was left unfixable. The solution you''ll have to do is to use `:url` form_for @alpha, :url => alpha_path On Tue, Jul 12, 2011 at 4:23 PM, elfo <michaelelfassy@gmail.com> wrote:> There seems to be a small bug with has_one relationships and resource > in the routes. > Example: > > where beta has_one alpha > > In routes: > resource alpha > > In view: > > form_for @alpha --> automatic link is alpah_path(id) and not > alpha_path > and in this case since there is no id in the route, the id takes the > place of the format param -> /alpha.1 > > Thanks! > Mike > > -- > 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.
What about making the polymorphic routing in rails to try a plural route first. If it fails, try a singleton route. If it fails, raise. This is not the nicest and most performant way (the result could be cached in production so it doesn''t really matter in the end) but I guess it should solve most cases. Or is this too much magic? Corin On 13.07.2011 00:17, Prem Sichanugrist wrote:> There have been a lot discussion about this a while ago. However, we > couldn''t find the way to determine the correct route to use when you > have a singular resource, so it was left unfixable. > > The solution you''ll have to do is to use `:url` > > form_for @alpha, :url => alpha_path > > On Tue, Jul 12, 2011 at 4:23 PM, elfo <michaelelfassy@gmail.com > <mailto:michaelelfassy@gmail.com>> wrote: > > There seems to be a small bug with has_one relationships and resource > in the routes. > Example: > > where beta has_one alpha > > In routes: > resource alpha > > In view: > > form_for @alpha --> automatic link is alpah_path(id) and not > alpha_path > and in this case since there is no id in the route, the id takes the > place of the format param -> /alpha.1 > > Thanks! > Mike > > -- > 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 > <mailto:rubyonrails-core@googlegroups.com>. > To unsubscribe from this group, send email to > rubyonrails-core+unsubscribe@googlegroups.com > <mailto:rubyonrails-core%2Bunsubscribe@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.-- 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.
I was thinking about the same thing too, but something was blocking me at that moment. Do you mind digging into the source code and see if it''s possible from your perspective, and then send a pull request if you can patch it? Thanks a lot! :) On Wed, Jul 13, 2011 at 3:20 AM, Corin Langosch <corin.langosch@netskin.com>wrote:> ** > What about making the polymorphic routing in rails to try a plural route > first. If it fails, try a singleton route. If it fails, raise. > > This is not the nicest and most performant way (the result could be cached > in production so it doesn''t really matter in the end) but I guess it should > solve most cases. Or is this too much magic? > > Corin > > > On 13.07.2011 00:17, Prem Sichanugrist wrote: > > There have been a lot discussion about this a while ago. However, we > couldn''t find the way to determine the correct route to use when you have a > singular resource, so it was left unfixable. > > The solution you''ll have to do is to use `:url` > > form_for @alpha, :url => alpha_path > > On Tue, Jul 12, 2011 at 4:23 PM, elfo <michaelelfassy@gmail.com> wrote: > >> There seems to be a small bug with has_one relationships and resource >> in the routes. >> Example: >> >> where beta has_one alpha >> >> In routes: >> resource alpha >> >> In view: >> >> form_for @alpha --> automatic link is alpah_path(id) and not >> alpha_path >> and in this case since there is no id in the route, the id takes the >> place of the format param -> /alpha.1 >> >> Thanks! >> Mike >> >> -- >> 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. > > -- > 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.
On 13 Jul 2011, at 08:20, Corin Langosch wrote:> What about making the polymorphic routing in rails to try a plural route first. If it fails, try a singleton route. If it fails, raise. > > This is not the nicest and most performant way (the result could be cached in production so it doesn''t really matter in the end) but I guess it should solve most cases. Or is this too much magic?That''s certainly one of the solutions I''ve thought about and I''ve got a GitHub issue (#1769) assigned to me regarding this issue so it''s on my todo list once 3.1 has shipped. 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.
ORLY? I didn''t see that ticket. Lemme have a look! On Wed, Jul 13, 2011 at 7:50 AM, Andrew White <andyw@pixeltrix.co.uk> wrote:> > On 13 Jul 2011, at 08:20, Corin Langosch wrote: > > > What about making the polymorphic routing in rails to try a plural route > first. If it fails, try a singleton route. If it fails, raise. > > > > This is not the nicest and most performant way (the result could be > cached in production so it doesn''t really matter in the end) but I guess it > should solve most cases. Or is this too much magic? > > > That''s certainly one of the solutions I''ve thought about and I''ve got a > GitHub issue (#1769) assigned to me regarding this issue so it''s on my todo > list once 3.1 has shipped. > > > 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. > >-- 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.