I think I have it!  I've reproduced this without using a plugin or engines, so the behaviour is to do with rails.  Question is whether this is expected behaviour or not?  Or whether it should be expected behaviour for rails:

Assumptions

[1] To allow a link_to entry to be populated in an application wide layout it needs to work from anywhere.  The suggested mechanism to achieve this is by putting a "/" at the front of the ":controller => ' /xxx'" part of "link_to" to make it absolute

[2] If a route starts with say ":locale" (e.g. "map.connect ':locale/grandad', etc") then when constructing a link_to there is no need to put this in place as it should be automatically populated if there is a ':locale' variable in params.  This seems to generally work.

Issue

[3] When a "link_to" entry in a view file uses the absolute path approach (from [1] above) it would seem that it then prevents the concept described in [2] from occuring.

Possible Workarounds

[4] Placing a default value of :locale in the routes.rb route gets the link_to to generate however obviously that won't really help by hard-coding a specific locale in.  That is this routes.rb default seems to be used in the link_to generation, even though an available params[:locale] parameter will not.

[5] Placing dynamically generated value for :locale in every link_to.  Not ideal from a DRY concept.  Example: 
         link_to 'my link', { :locale => '#{params[:locale]}', :controller => '/parent/child', :action ="" 'testaction' }

Resolution

[6] Update to rails ( routes.rb??) to allow a "params" value to be used when constructing a link_to or url_for even when the specified controller is an absolute path (e.g. / ).   

Aside - I still don't really understand why rails would allow the concept of specifying relative and absolute controllers?  Shouldn't they all be absolute?


Comments?  Do people agree?


Tks
Greg
























--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/rubyonrails-core
-~----------~----~----~----~------~----~------~--~---

Reply via email to