On Fri, 2006-04-14 at 23:16 -0600, Pat M. wrote:
use Role.create instead, as Role.new doesn’t save the record
On 4/14/06, Craig W. [email protected] wrote:
I want to create table called roles and then populate it with some new
records…This doesn’t work. Is there something I’m missing?
bingo thanks…ok, one follow up question then…
another section of my migrations creates a join table…
create_table :rights_roles, :id => false do |t|
t.column "right_id", :integer
t.column "role_id", :integer
and that’s fine, but I am adding data to rights table and to roles table
but the join table isn’t getting populated. So I figured I would do it
afterwards this way…
Right.find(:all).each do |ri|
ro = Role.find(:first, :conditions => :name == ri.name)
RightsRoles.create :right_id => ri, :role_id => ro
but when I run the migration, I get the following error…
PGError: ERROR: relation “rights_roles_id_seq” does not exist
: SELECT currval(‘rights_roles_id_seq’)
and of course, the relation “rights_roles_id_seq” doesn’t exist because
I told it not to create it above.
How do I populate a join table (or do I?) when I set values to the 2
tables being joined in migration?