I am trying to show a form on the contact page, but it is from another controller.
The current code results in "First argument in form cannot contain nil or be empty"
After searching it looks there is a problem with the local hash that is not passed.
How can I correctly pass the locals with this code so that it works?
inquiries_controller.rb
class InquiriesController < ApplicationController
def new
@inquiry = Inquiry.new
end
def create
@inquiry = Inquiry.new(params[:inquiry])
if @inquiry.deliver
render :thank_you
else
render :new
end
end
end
inquiries_form.html.erb
<%= form_for @inquiry do |f|
f.text_field :name
f.text_field :email
f.text_area :message
f.submit "Send"
end %>
static_pages\contact.html.erb
<%= render "inquiries/form",
:inquiry => @inquiry %>
:inquiry => @inquirysets a local variable (no @) namedinquiry, whereas your form expects an instance variable (@).