I have a form to create a new Player in /players/new.html.erb
<%= form_for(@player) do |f| %>
...
<% end %>
which I want to include in the home page.
If I just copy-paste the whole form I get this error: undefined methodmodel_name’ for NilClass:Class`
I can include the form in an iframe
<div>
<iframe src=../players/new.html>
</div>
but this shows the whole page with headers and footers.
How can I include the form, ideally directly from the file (i.e. no copy-paste)?
your
form_forrequires at least@playerto be presentif you really want to include that form on your home page then in your home controller action initialize new Player instance:
but you must be aware that views of
PlayerController(or whatever controller you have that form created for) can rely on having access to helper methods fromPlayerHelperso you might need to also include that in yourHomeHelper