我正在使用ruby 1.8.7和rails 3.2.13。我想用formtastic创建一个表单。我一直收到错误“NilClass:Class的未定义方法`model_name'”。以下是我的控制器,路线和索引:
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 %>
非常感谢任何帮助!提前谢谢!
答案 0 :(得分:1)
我实际上忘了创建一个模型......对于其他任何错误,请确保为您引用的任何对象创建模型...