联系表单未显示在页面上

时间:2015-05-29 15:51:28

标签: html ruby-on-rails simple-form

嘿我正在尝试为我的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>

指向我的联系人/新链接的链接正常但我的联系表单未显示在页面上。

2 个答案:

答案 0 :(得分:2)

应为<%=simple_form_for @contact do |t|%>

答案 1 :(得分:1)

你应该写你的simple_form_for <%= simple_form_for %>