I am RoR noob so this might be a simple problem for someone. I have created two models - User and Feedback and I have two tables associated with them. users and feedbacks.
Now I want to create a relationship table with user_id as one column and feeback_id as the other column.
Do I create a model or just a migration? I am confused.
Here are my user and feedback migrations.
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string "first_name"
t.string "last_name"
t.string "email"
t.string "phone"
t.string "password_hashed"
t.string "password_salt"
t.boolean "isdeleted", :default => false
t.timestamps
end
end
def self.down
drop_table :users
end
end
class CreateFeedbacks < ActiveRecord::Migration
def self.up
create_table :feedbacks do |t|
t.text "feedback"
t.integer "rating"
t.boolean "isdeleted", :default => false
t.timestamps
end
end
def self.down
drop_table :feedbacks
end
end
Now do I create a model??? >rails generate model FeedbackUserJoinTable ? Or just a migration like this ??
class CreateFeedbackUserJoinTable < ActiveRecord::Migration
def change
create_table :feedbacks_users, :id => false do |t|
t.integer :feedback_id
t.integer :user_id
end
end
end