Undefined method f_title

Hi,

This is my migration:

class CreateSampleForms < ActiveRecord::Migration

def self.add_data

SampleForm.create(:name => ‘Default (Empty)’, :f_type => ‘Default (Empty)’, :description => ‘Use this template to create a blank form.’)

end

def self.up

create_table :sample_forms do |t|

t.string :name, :null => false

t.string :f_title

t.text :description

t.timestamps

end

self.add_data

end

def self.down

drop_table :sample_forms

end

end

While migrating, it gives the error ‘undefined method f_title=’. I first thought ‘title’ was reserved so I renamed it to ‘f_title’. When I remove it, the process starts over with the description attribute.

CmdJohnson

Try this:

class CreateSampleForms < ActiveRecord::Migration
  def self.add_data
    SampleForm.create(:name => 'Default (Empty)', :f_type => 'Default
(Empty)', :description => 'Use this template to create a blank form.')
  end

  def self.up
    create_table :sample_forms do |t|
      t.string :name, :null => false
      t.string :f_title
      t.text :description

      t.timestamps
    end
    SampleForm.reset_column_information
    self.add_data
  end

  def self.down
    drop_table :sample_forms
  end
end

To no avail:

== 20081023195916 CreateSampleForms: migrating ================================

– create_table(:sample_forms)

-> 0.0610s

rake aborted!

undefined method `f_type=’ for #SampleForm:0x16856e3

rake aborted!

Hi,

Rails doesn’t like the model name SampleForm.

I created a scaffold called Tent with the same attributes which does work.

CmdJohnson