开发者

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 )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜