Including a form from a separate file with Ruby on Rails -
i have form create new player
in /players/new.html.erb
<%= form_for(@player) |f| %> ... <% end %>
which want include in home page.
if copy-paste whole form error: undefined method
model_name' nilclass:class`
i can include form in iframe
<div> <iframe src=../players/new.html> </div>
but shows whole page headers , footers.
how can include form, ideally directly file (i.e. no copy-paste)?
your form_for
requires @ least @player
present
if want include form on home page in home controller action initialize new player instance:
@player = player.new
but must aware views of playercontroller
(or whatever controller have form created for) can rely on having access helper methods playerhelper
might need include in homehelper
Comments
Post a Comment