Seed_fu and has_many :through

Hi
In my application to seed data I am using seed_fu
(http://github.com/mbleigh/seed-fu)

I have tables roles,privileges and permissions( It joins roles and

privileges). Now at application startup I have to seed these tables with
data. But during runtime some additionals rows may be added to
permissions. But I dont how at a later stage if I run rake db:seed_fu
all data that I set later to permissions may be wipeout. I dont know how
to handle this.

As an example

role

1 admin
2 contact
3 employee

privilege

1 add_contact
2 edit_contact
3 delete_employee

permissions (role_id,privilege_id)

1 1
1 2
3 2 …etc

  Suppose this may be seeded at startup. Later additional entries

may go to permissions. One of my question is how can I use seed_fu to
fill data for permissions table? Can I do it as usual like create
db/fixtures/permission.rb and

Permission.seed_many(:id, :id, [
{ :role_id => 1, :privilege_id => 1 },
{ :role_id => 1, :privilege_id => 2 },
{ :role_id => 3, :privilege_id => 2 }
])

 One more question is if I follow like above and at a later stage if

run rake db:seed_fu again all data that where added later to permission
will be lost. And also how can I ensure that all the id values above
should be what I expected. Please guide me

Thanks in advance
Tom

On 29 March 2010 13:22, Tom M. [email protected] wrote:

Hi
In my application to seed data I am using seed_fu
(http://github.com/mbleigh/seed-fu)

I have tables roles,privileges and permissions( It joins roles and
privileges). Now at application startup I have to seed these tables with
data. But during runtime some additionals rows may be added to
permissions. But I dont how at a later stage if I run rake db:seed_fu
all data that I set later to permissions may be wipeout. I dont know how
to handle this.

This is presumably a follow on to your previous thread. You never
explained why you are repeatedly seeding the database, this is
normally something that would be done only once.

Colin

Hi Colin

Suppose I have the development phases like phase1,phase2, etc. So 

for example in Phase1 I have to seed data to say table1 (rake
db:seed_fu) And it is deployed.
Now again in phase2 again I have to seed data to table2 . Then also to
sseed data I run
rake db:seed_fu

    But when ever I run this command it seeds data to table1 (once 

more) and table2 (for the first time). Is n’t it? I think I can answer
your question. But could you please give answer to my original questions
posted in this thread.

Thanks
Tom

On 30 March 2010 05:05, Tom M. [email protected] wrote:

more) and table2 (for the first time). Is n’t it? I think I can answer
your question. But could you please give answer to my original questions
posted in this thread.

Remove the data for the first table from the seed code once you have
done it, so that the next time it just seeds the second one. You can
always get the old version back from your version control system if
you ever need it again.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs