Had this error when trying to add comments to another user's photo.
ActiveRecord::StatementInvalid in User photosController#show
Mysql::Error: Unknown column 'comments.user_id' in 'on clause': SELECT
photos.`id` AS t0_r0, photos.`user_id` AS t0_r1, photos.`title` AS
t0_r2, photos.`body` AS t0_r3, photos.`created_at` AS t0....
I did create a user_id column in the comments as such:
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
t.column :photo_id, :integer
t.column :user_id, :integer
t.column :guest_name, :string
t.column :guest_email, :string
t.column :guest_url, :string
t.column :body, :text
t.column :created_at, :datetime
end
add_index :comments, :photo_id
end
def self.down
drop_table :comments
end
end
Can anyone tell me what went wrong and how to solve?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---