Question

I'm using ruby 1.8.7 and rails 3.2.13. I want to create a form using formtastic. I keep getting the error "undefined method `model_name' for NilClass:Class". Following is my controller, routes, and index:

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 %>

Any help is greatly appreciated! Thank you in advance!

Was it helpful?

Solution

I actually forgot to create a model... For anyone else getting an error make sure you create a model for whatever object you are referencing...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top