Thank you very much for this valuable information.

And I've stumble upon another problem: migrations.

I want to add additional columns and my table in the database which is already set up (this is still development).

I did as it's described in the camping book and put another migration with increased version number (I've deleted most columns here for brevity):

------------------------------------------------
  class BasicFields < V 1.0
    def self.up
      create_table Reviewform.table_name do |t|
        t.string    :title
        t.string    :translator
        t.timestamps
      end
    end

    def self.down
      drop_table Reviewform.table_name
    end
  end

  class AdditionalBasicFields < V 1.1
    def self.change
      add_column Reviewform.table_name, :wrong_translation, :string
        Reviewform.reset_column_information
    end

    def self.down
      drop_table Reviewform.table_name
    end
  end
-----------------------------------------------------------


And at the end of the file I have as usual:
-----------------------------------------------------------
def Review.create
  Review::Models.create_schema
end
----------------------------------------------------------

This throws this error at me when creating a new form:

ActiveRecord::UnknownAttributeError at /form/new

unknown attribute: wrong_translation
Ruby /home/sebastjan/.rvm/gems/ruby-2.1.1/gems/activerecord-4.0.4/lib/active_record/attribute_assignment.rb: in rescue in _assign_attribute, line 47

Web    POST localhost/form/new


I also tried doing this as described in ActiveRecord API:
----------------------------------------------------------------------------------------
  class AdditionalBasicFields < V 1.1

    def self.change
      change_table :reviewforms do |t|
        t.integer :wrong_translation
      end
    end

    def self.down
      drop_table Reviewform.table_name
    end

  end
------------------------------------------------------------------------------------------

And I get the same error. The table is not changed.

I can't find the mistake I've made.

Need help:(
regards,
seba

_______________________________________________
Camping-list mailing list
Camping-list@rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

Reply via email to