Rails fixtures or similar for creating data within an app
I want to populate a preferences table when a user is created. I can make a lash up version within the controller easily enough but would like something neater.
Can on开发者_开发技巧e do the same sort of thing with fixtures within a running application? If so how?
You could search for a gem. I've used https://github.com/FooBarWidget/default_value_for some time ago for a similar thing. It's a nice and clean solution.
In the end I simple defined an array in the model and array.each -ed it. Not perhaps the most elegant but still have all the values in one place for editing.
精彩评论