I almost always use attr_accessible
in my Rails models.
Is there a generator flag or other terminal command to haveattr_accessible
and the model fields automatically inserted into the model file when I run a relevant generator?
I almost always use attr_accessible
in my Rails models.
Is there a generator flag or other terminal command to haveattr_accessible
and the model fields automatically inserted into the model file when I run a relevant generator?
Not sure about that. But you can annotate your models using this gem.
It will add schema info in the model files as comments at the top of the file. Maybe that could help you in some way to create attr_accessible
fields.
Rails airs on the opinion that all the fields are accessible (outside of ID) unless you don't want them to be.
You could write your own generators to override the default ones if it's a major pain point. One thing I suggest is, that if your attr_accessible
is a lot of work for you to do for each model, would using attr_protected
be better suited for your tasks?