Skip to content

Instantly share code, notes, and snippets.

@onslauth
Created June 21, 2013 12:22
Show Gist options
  • Save onslauth/5830815 to your computer and use it in GitHub Desktop.
Save onslauth/5830815 to your computer and use it in GitHub Desktop.
resources :a do
resources :b do
resources :c
end
end
Controller c
before_action :set_parents
...
def set_parents
@parents = []
@a = A.find( params[:a_id] )
@parents << @a
@b = B.find( params[:b_id] )
@parents << @b
end
c/views/new.html.erb
<%= link_to 'Back', url_for( @parents ) %> results in a link to /a/1/b/2/c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment