I''ve searched around and have not found a way to add a reference
column to an existing table, I guess it would be something like
class AddProjectReferenceToTask < ActiveRecord::Migration
def self.up
add_reference :tasks, :projects
end
def self.down
remove_reference :tasks, :projects
end
end
of course the methods don''t exist but you get an idea of what the
problem is, man I need that AWDR for 2.0...
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Um, you mean an association, right? I''m assuming it''s a HABTM one, def self.up create_table :projects_tasks, :id => false do |t| t.integer :project_id, :task_id end end self def self.down drop_table :projects_tasks end --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
now I see what the problem was, I thought that by doing t.references :project the migration would do the reference on mysql, instead of just creating the field for the FK. It''s a one to many so all I had to do to add the reference was add_column :tasks, :project_id, :integer On Jan 3, 5:30 am, "Ryan Bigg" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Um, you mean an association, right? > > I''m assuming it''s a HABTM one, > def self.up > create_table :projects_tasks, :id => false do |t| > t.integer :project_id, :task_id > end > end > self > > def self.down > drop_table :projects_tasks > end--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---