uninitialized constant add_column2::Tier3DiscountGroup

9 views
Skip to first unread message

tom

unread,
Jan 19, 2015, 5:27:19 PM1/19/15
to Ruby on Rails: Talk
hi, im getting the error outlined in the subject. this is the migration:
add_column :tier_3_discount_groups, :description, :text  unless Tier3DiscountGroup.column_names.include?('description')


here is the model:
filename: 
tier_3_discount_group.rb
content:
class Tier3DiscountGroup < ActiveRecord::Base
end


create-migration:
filename:
20141209204148_create_tier_3_discountount_groups.rb
content:
class CreateTier3DiscountountGroups < ActiveRecord::Migration
  def change
    create_table :tier_3_discountount_groups do |t|
      t.string :name
      t.timestamps
    end
  end
end


> where is my mistake?

thx


Daniel Loureiro

unread,
Jan 19, 2015, 7:39:09 PM1/19/15
to rubyonra...@googlegroups.com
you know there is a typo, right? "CreateTier3DiscountountGroups" (on database your table is named "tier_3_discountount_groups" or "tier_3_discount_groups"?). Also, you can use "column_exists?", like this:

add_column :tier_3_discount_groups, :description, :text  unless column_exists? :tier_3_discount_groups, :description


--
Daniel Loureiro
Reply all
Reply to author
Forward
0 new messages