Я хочу создать форму без использования Active Record, я следую учебному пособию по Ruby on Rails и использую Active Model, поэтому у меня есть модель
class GoodsPurchase
include ActiveModel::Validations
include ActiveModel::Conversion
include ActiveModel::Model
extend ActiveModel::Naming
attr_accessor :phone, :name, :email
validates_presence_of :phone
validates_presence_of :name
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i
def initialize(attributes = {})
super
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
end
тогда у меня есть контроллер
class Market::Desktop::Vision::GoodsPurchaseController < CatalogController
domain_layout 'page_screen'
def create_message
@goods = GoodsPurchase.new message_params
if @goods.valid?
flash[:notice] = "Message sent! Thank you for contacting us."
redirect_to root_url
else
render :action => 'new'
end
end
private
def message_params
params.require(:goods).permit(:phone, :name, :email)
end
end
И просмотр
<%= form_for @goods, url: goods_purchase_create_message_url, method: :post, remote: true do |f| %>
<div class="row">
<%= f.label :Phone, class: "label" %>
<%= f.text_field :phone, class: "int", placeholder: "+7 ( ) 123-45-67", :required => true %>
</div>
<div class="row">
<%= f.label :Name, class: "label" %>
<%= f.text_field :name, class: "int", placeholder: "Oleg Petrov", :required => true %>
</div>
<div class="row">
<%= f.label :Email, class: "label" %>
<%= f.text_field :email, class: "int", placeholder: "example@example.ru", :required => true %>
</div>
<input type="hidden" name="articul_for_order" class="js_articul_for_order">
<div class="row">
<%= recaptcha_tags %>
</div>
<button type="" class="btn btn_middle btn_blue2">Order callback`enter code here`</button>
<%= f.submit "Callback", class: 'btn btn_middle btn_blue2' %>
<% end %>
А в route.rb я написал post "goods_purchase/create_message"
И после этого у меня появляется эта ошибка first argument in form cannot contain nil
Я не знаю почему и что мне с ней делать