Form_for with nested shallow route

Let’s say I have:

map.resources :teams do |team|
team.resources :squads, :shallow => true

When I want to generate a form_for a squad, I need both the team and
squad for new/create, but only the squad for edit.

This means I need:


form_for([team, squad])

This seems not very dry. Is there a more idiomatic way of doing this?

Right now, I’ve abbreviated to:

form_for(team = team ? [team, squad] : squad)

(the team=team assignment makes sure there is no error if team is not

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs