简体   繁体   中英

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 one 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM