db:seed - How to change a value on production?
I have the following db:seed which is live on heroku:
["Admin", "Member"].each do |role_name|
Role.find_or_create_by_name(role_name)
end
Admin is ID=1 and Member is ID = 2, which is important to the entire ap开发者_开发技巧p.
I want to change Member to Teammember,
how do I do that? if I delete the old records and reseed then the ID's will be off?
Suggestions?
Just do:
member = Role.find_by_name("Member")
member.name = "Teammember"
member.save!
PS: don't rely on ID in your code ( use Role.find_by_name )
精彩评论