How can I design my view such that it "remembers" its route? So that "Back" on /team/1/members/1
links to /team/1/members
and /members/1
links back to /members
?
I have models of team
and member
. Teams have many members.
My routes allow me to view all member or members on a team.
resources :teams do
resources :members
end
resources :members do
resources :member_parts
end
I've currently tried to keep the route consistent. But doing so I seem to have to repeat myself a lot and add many bits of logic to the view. (this just seems wrong)
excerpt from app/views/members/show.html.erb
<%= link_to 'Edit', params[:team_id].nil? ? edit_member_path(@member) : edit_team_member_path(@member.team,@member) %> |
<%= link_to 'Back', params[:team_id].nil? ? members_path : team_members_path(@member.team) %>