On Thu, Jul 14, 2011 at 12:10 PM, Michael P. [email protected]
wrote:
On 14 July 2011 16:47, joanne ta [email protected] wrote:
in language model
belongs_to :name_id, :class_name => “Phrase”, :foreign_key => “name_id”
Why would you change the association name to “name_id”? It’s just the
foreign key to change:
belongs_to :name, :class_name => “Phrase”, :foreign_key => “name_id”
i changed it
now it gives me an error
Error:
test_validates_length_of_name(UserTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: table languages
has
no column named name_id: INSERT INTO “languages” (“name_english”,
“name_id”,
“created_at”, “updated_at”, “id”) VALUES (‘en’, ‘english’, ‘MyString’,
1,
‘f’, ‘MyString’, 1, ‘2011-07-14 16:22:20’, ‘2011-07-14 16:22:20’,
-
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract_adapter.rb:207:in
`rescue in log’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract_adapter.rb:199:in
`log’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/sqlite_adapter.rb:135:in
`execute’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:239:in
`insert_fixture’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:652:in
`block in insert_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:588:in
`each’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:588:in
`insert_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:532:in
`block (4 levels) in create_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:532:in
`each’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:532:in
`block (3 levels) in create_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in
`transaction’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:530:in
`block (2 levels) in create_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract_adapter.rb:109:in
`disable_referential_integrity’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:521:in
`block in create_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/benchmarkable.rb:55:in
`silence’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:520:in
`create_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:979:in
`load_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/fixtures.rb:944:in
`setup_fixtures’
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/callbacks.rb:415:in
`_run_setup_callbacks’
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/testing/setup_and_teardown.rb:34:in
`run’
in yml file
one:
name_english: english
name_id: 1
two:
name_english: french
name_id: 1