[Rails] Re: Dynamic Paths

2009-12-03 Thread David
Maybe something like this would work: in the user model: has_many :posts, :dependent => :destroy def to_param username end in the route: map.resources :posts, :path_prefix => ":username" Then in the view: post_url(post, :username => "donaldduck") In the controller: user = User.find_by_usernam

[Rails] Re: dynamic paths

2009-07-13 Thread Bob O
After diving into a few mentioned scenarios (thanks Frederick) the polymorphic_path and polymorphic_url is what i was looking for. thanks guys B On Jul 13, 7:40 am, Bob O wrote: > Let me see if i can be more clear, and i will try some of the > suggested solutions > > Im trying to make the rout

[Rails] Re: dynamic paths

2009-07-13 Thread Bob O
Let me see if i can be more clear, and i will try some of the suggested solutions Im trying to make the route paths dynamic. Lets say I have 2 models document, and article I would have paths like document_path(document), documents_path, new_document_path etc... and similar for article article_p

[Rails] Re: dynamic paths

2009-07-11 Thread Matt Jones
If your routes are set up in the default RESTful style, then you should just be able to call: <%= link_to 'show', object %> ...and the routing system will get what you mean. If things are more complicated, you may need of the other solutions here. Or, you could call a named route like this: <%=

[Rails] Re: dynamic paths

2009-07-11 Thread Frederick Cheung
On Jul 10, 11:17 pm, Bob O wrote: > does anyone know how i can make dynamic paths? > > say i had a partial for maybe an index list, but i want the link to > the show page to be dynamic so im able to use the partial for may > objects. > > <%= link_to "show", "#{object}" + _path(object) %> > > so

[Rails] Re: dynamic paths

2009-07-10 Thread Älphä Blüë
Hi Bob, It depends on how you have your controllers setup - really. For instance, I have a Universal controller template that 37 other controllers use. class UniversalTemplatesController < ApplicationController def index @objects = params[:controller].singularize.camelize.constantize.f

[Rails] Re: dynamic paths

2009-07-10 Thread Bob O
excellent. thank you. i further step. I have a polymorphic association where im trying to achieve something similar. im feeding an xml file to a swf. the xml iterates over the poly model, but it belongs_to many different objects. but the xml file is called from the poly controller. so the abo

[Rails] Re: dynamic paths

2009-07-10 Thread Älphä Blüë
Bob O wrote: > does anyone know how i can make dynamic paths? > > say i had a partial for maybe an index list, but i want the link to > the show page to be dynamic so im able to use the partial for may > objects. > > <%= link_to "show", "#{object}" + _path(object) %> > > something along those l