rubyonrailsin

A Ruby and Rails talk

Monday, March 29, 2010


[Rails] Re: seed data

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

Hi
Thanks for your reply

> Could you explain what you're trying to do in a step by step scenario?
> This
> may helper others on the mailing list to better assist you.

What I tried is as my first post. Now just as a test a I did like

State.destroy_all
State.create(:id => 1,:name => "Alabama", :abbr => 'AL',:fips => '01',
:country_id => 1)

But after this step whenever I do rake db:seed_fu

I dont get what I expected for the id fields. I expect id to be
generated like
1,2,3....

> If you really need the id to be pre-defined (though why you need to do
> this I do not know, it is generally a bad idea)

Why I need the id to be predefined means suppose at a later stage
if already that id may e saved to a number of tables as foreign key. But
suppose if execute rake db:seed_fu then if the id changed to 5,6,7
instead of 1,2,3
the total solution may be a big fail
So when I checked the way which I mentioned in my first post
accidently I noticed this. Then post a message to a get a clarification
since I dont know where the fault is

I think one more thing to ensure the ids are the values that I
expected is, after creation call a function like

@country.update_id_to(1) .....


Thanks
Tom

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive