Programmatically add a route

Is there a way to programmartically add a route? I have an outside
process creating pages that I need to access, but I dont know their
names or locations until runtime. -Janna B

Janna Brossard wrote:

Is there a way to programmartically add a route? I have an outside
process creating pages that I need to access, but I dont know their
names or locations until runtime. -Janna B

Janna,

Sounds messy! Are you sure this is the best option?

What is it you’re trying to achieve?

Gavin

I’m not sure but it seems possible to have a route at the end of your
routes
file (with the lowest priority) that would handle any un-handled
requests.
You could then dispatch it to wherever you want. Maybe there is a
better
way to do it though. Could you give some example URL’s?

On Wed, Jul 8, 2009 at 4:07 AM, Gavin M. <

Well, for example. I was going to have it write partials into /public/
blahblah/_mypartial!.erb

Janna Brossard wrote:

Well, for example. I was going to have it write partials into /public/
blahblah/_mypartial!.erb

map.connect “/blahblah/:partial_name”, :controller => “yourcontroller”,
:action => “your_action”

This would work provided you’re always routing to the same controller
and action.

I suppose in the action you’d just call something like

def my_action
render :partial => params[:partial_name]
end

not 100% sure if that would work the way you want it to though.

Can you elaborate a little more?

Gavin

You can add a static file system path to your render call with the :file
option

2009/7/8, Gavin M. [email protected]:

http://handyrailstips.com

Posted via http://www.ruby-forum.com/.


Von meinen Mobilgerät aus gesendet

Now that I think about it - don’t think this would work

render looks through the view folders for your partial - not sure if
you’d be able to store them in the public directory

:S

Gavi