Consider a team of players.
I would like to make my _form not include the form header. This would allow me to have different fields available when depending on whether I am editing or creating a new player. It also allows me reuse that form as a partial when building a larger editor page that could say edit 2 players at one.
Creating Player<%= form_for(@player) do |f| %> <%= render 'form' %>
Editing Player<%= form_for(@player) do |f| %> <%= render 'form' %> <%= f.submit %> <% end %>
Editing Roster<%= form_for(@roster) do |f| %> <%= render 'players/form', @roster.first_player %> <%= render 'players/form', @roster.second_player %> <%= f.submit %> <% end %>
I use this pattern all the time with MS-MVC/EF/C#. Is this bad practice in rails? The syntax I have given doesn’t quite work, so I guess if I go with this, I’ll have to change the new/edit/_form for each one I want to do this with. Even the generate _form won’t work, as I don’t have access to |f|, in my partial.
What is the ‘railsy’ way of accomplishing this?