How to set default values in Rails?

后端 未结 17 1366
醉话见心
醉话见心 2020-11-28 04:39

I\'m trying to find the best way to set default values for objects in Rails.

The best I can think of is to set the default value in the new method in

17条回答
  •  感情败类
    2020-11-28 04:44

    If you are just setting defaults for certain attributes of a database backed model I'd consider using sql default column values - can you clarify what types of defaults you are using?

    There are a number of approaches to handle it, this plugin looks like an interesting option.

提交回复
热议问题