联系表未显示在页面上
Contact form not displaying on the page
嘿,我正在尝试为我的 rails 应用程序创建联系页面。我创建了一个联系人模型:
class Contact < ActiveRecord::Base
end
一个触点控制器:
class ContactsController < ApplicationController
skip_after_action :verify_authorized
def new
@contact = Contact.new
end
def create
end
end
运行 一次迁移:
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :email
t.string :object
t.text :content
t.timestamps null: false
end
end
end
我也创建了一条路线
resources :contacts, only: [:new, :create]
并创建了一个视图:
<div class="banner">
<div class="container">
<div class= "col-xs-12">
<%simple_form_for @contact do |t|%>
<%= t.error_notification %>
<%= t.input :email, label: 'Votre email' %>
<%= t.input :object, label: 'Objet' %>
<%= t.input :content, label: 'Votre Message' %>
<%= t.button :submit, value: "Soumettre ce tournoi à validation", class: "btn-primary marge-bas" %>
<% end -%>
</div>
</div></div>
我的 contacts/new 的 link 工作正常,但页面上没有显示我的联系表。
你应该这样写 simple_form_for
<%= simple_form_for %>
应该是<%=simple_form_for @contact do |t|%>
嘿,我正在尝试为我的 rails 应用程序创建联系页面。我创建了一个联系人模型:
class Contact < ActiveRecord::Base
end
一个触点控制器:
class ContactsController < ApplicationController
skip_after_action :verify_authorized
def new
@contact = Contact.new
end
def create
end
end
运行 一次迁移:
class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.string :email
t.string :object
t.text :content
t.timestamps null: false
end
end
end
我也创建了一条路线
resources :contacts, only: [:new, :create]
并创建了一个视图:
<div class="banner">
<div class="container">
<div class= "col-xs-12">
<%simple_form_for @contact do |t|%>
<%= t.error_notification %>
<%= t.input :email, label: 'Votre email' %>
<%= t.input :object, label: 'Objet' %>
<%= t.input :content, label: 'Votre Message' %>
<%= t.button :submit, value: "Soumettre ce tournoi à validation", class: "btn-primary marge-bas" %>
<% end -%>
</div>
</div></div>
我的 contacts/new 的 link 工作正常,但页面上没有显示我的联系表。
你应该这样写 simple_form_for
<%= simple_form_for %>
应该是<%=simple_form_for @contact do |t|%>