Seem to be mis-understanding how url_for *should* work. In my routes.rb I have the following line: map.connect ":my_template/:page", :controller => ''page'', :action => "view" Now I want to try and generate a url for this an a different module, say under admin/whatever. I could just hard code it in using "/template1/page1" but thats not very nice, so I''m trying to use the url_for method. Everything I''ve read says something like: <a href="<%= url_for(:my_template => page.my_template.path, :page => page.name) %>"> and all I get are the parameters passed as html get attributes (/?my_template=whatever&page=something). What want is /whatever/something I''ve tried using the :controller attribute to set it "", "/", "page" and everthing else I could thing of, all with out the expected results. I''ve also tried using :controller_prefix attribute, but that just got added to the request attributes. Thanks for the help! -Nick
On 19.10.2005, at 21.42, Nick Stuart wrote:> Seem to be mis-understanding how url_for *should* work. In my > routes.rb I have the following line: > > map.connect ":my_template/:page", :controller => ''page'', :action => > "view" > > Now I want to try and generate a url for this an a different module, > say under admin/whatever. I could just hard code it in using > "/template1/page1" but thats not very nice, so I''m trying to use the > url_for method. Everything I''ve read says something like: > > <a href="<%= url_for(:my_template => page.my_template.path, :page => > page.name) %>">You also need to specify the action, otherwise rails thinks you refer to the default action, i.e. "index". Thus your route above doesn''t match to this url. //jarkko> > and all I get are the parameters passed as html get attributes > (/?my_template=whatever&page=something). What want is > /whatever/something > > I''ve tried using the :controller attribute to set it "", "/", "page" > and everthing else I could thing of, all with out the expected > results. I''ve also tried using :controller_prefix attribute, but that > just got added to the request attributes. > > Thanks for the help! > -Nick > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Ah, see, now I just thought it did the matching from the first part of the Route (:my_template/:page in my case). I''ll try adding the action in and see what happens. Although for the most part it seems I''ve aliviated some of this using named routes which are working and producing what I want. Thanks for the tip! -Nick On 10/20/05, Jarkko Laine <jarkko-k1O+Gnc6WpmsTnJN9+BGXg@public.gmane.org> wrote:> > On 19.10.2005, at 21.42, Nick Stuart wrote: > > > Seem to be mis-understanding how url_for *should* work. In my > > routes.rb I have the following line: > > > > map.connect ":my_template/:page", :controller => ''page'', :action => > > "view" > > > > Now I want to try and generate a url for this an a different module, > > say under admin/whatever. I could just hard code it in using > > "/template1/page1" but thats not very nice, so I''m trying to use the > > url_for method. Everything I''ve read says something like: > > > > <a href="<%= url_for(:my_template => page.my_template.path, :page => > > page.name) %>"> > > You also need to specify the action, otherwise rails thinks you refer > to the default action, i.e. "index". Thus your route above doesn''t > match to this url. > > //jarkko > > > > > and all I get are the parameters passed as html get attributes > > (/?my_template=whatever&page=something). What want is > > /whatever/something > > > > I''ve tried using the :controller attribute to set it "", "/", "page" > > and everthing else I could thing of, all with out the expected > > results. I''ve also tried using :controller_prefix attribute, but that > > just got added to the request attributes. > > > > Thanks for the help! > > -Nick > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > -- > Jarkko Laine > http://jlaine.net > http://odesign.fi > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > >