Search code examples
ruby-on-railsrubyruby-on-rails-3.2actionpack

Getting 'form_for(@something)' to work outside of new.html.erb


I want to place my <%= form_for(@something) do |f| %> which is currently located in app/views/something/new.html -- inside multiple pages, so maybe in app/views/layouts/application.html.erb

How do I get the @something variable and the form to work properly there, or somewhere else -- since it's defined in the controller #new action of SomethingController, it only seems to be available in the appropriate new.html.erb view..


Solution

  • Try

    <%= form_for SomeThing.new do |f| %>