我正在使用 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
路线.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 %>
任何帮助是极大的赞赏!先感谢您!