Redirecting a model's path to a different path in Rails -


say have following in routes.rb:

resources :universes     resources :planets end 

this creates method, universe_planet_path(universe, planet). however, planet object knows universe belongs to, have planet_path(planet) function can return same url universe_planet_path(planet.universe, planet). should put such function such that, say, form_for @planet able access it, or there better way this?

to answer first part of question, in application_helper create function so:

def planet_path(planet)     universe_planet_path(planet.universe, planet) end 

not sure form_for part though, that's little bit more tricky.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -