2013-10-14 60 views
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 %> 

任何帮助非常感谢!先谢谢你!

回答

1

我实际上忘了创建一个模型...对于其他任何出现错误的人,请确保您创建了一个模型,以供您引用的任何对象...