Forum: Ruby on Rails Undefined method f_title

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7fe5937b838b580eeaa061c85f700583?d=identicon&s=25 Commander Johnson (Guest)
on 2008-10-26 11:12
(Received via mailing list)
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
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2008-10-26 11:38
(Received via mailing list)
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

On Sun, Oct 26, 2008 at 7:11 AM, Commander Johnson
<commanderjohnson@gmail.com> wrote:
>       t.string :name, :null => false
> 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
> >
>



--
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
João Pessoa, PB, +55 83 8867-7208
7fe5937b838b580eeaa061c85f700583?d=identicon&s=25 Commander Johnson (Guest)
on 2008-10-29 19:16
(Received via mailing list)
To no avail:

== 20081023195916 CreateSampleForms: migrating
================================
-- create_table(:sample_forms)
   -> 0.0610s
rake aborted!
undefined method `f_type=' for #<SampleForm:0x16856e3>
rake aborted!

On Sun, Oct 26, 2008 at 11:37 AM, Maurício Linhares <
7fe5937b838b580eeaa061c85f700583?d=identicon&s=25 Commander Johnson (Guest)
on 2008-10-29 20:32
(Received via mailing list)
Hi,
Rails doesn't like the model name SampleForm.

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

CmdJohnson

On Wed, Oct 29, 2008 at 7:15 PM, Commander Johnson <
This topic is locked and can not be replied to.