0
我使用的是ruby 1.8.7和rails 3.2.13。我想用formtastic創建一個表單。我不斷收到錯誤「NilClass:Class」的未定義方法`model_name'。以下是我的控制器,路線和指標:Formtastic undefined方法
App_pages_controller.rb:
class AppPagesController < ApplicationController
def index
end
def new
@person = Person.new
end
def create
@person = Person.new(params[:person])
if @person.save
redirect_to new_student_path
end
end
def registration
end
def unknown
end
end
的routes.rb:
WyspApp::Application.routes.draw do
resources :persons
match '/registration', :to => 'App_pages#registration'
match '/unknown', :to => 'App_pages#unknown'
match '/index', :to => 'App_pages#index'
root :to => 'App_pages#index'
index.html.erb
<%= semantic_form_for @person do |form| %>
<%= form.inputs do %>
<%= form.input :name %>
<%= form.input :born_on, :start_year => 1997 %>
<%= form.input :description, :as => :text %>
<%= form.input :female, :as => :radio, :label => "Gender", :collection => [["Male", false], ["Female", true]] %>
<% end %>
<%= form.actions do %>
<%= form.action :submit, :as => :button %>
<% end %>
<% end %>
任何幫助非常感謝!先謝謝你!