Option: include only attr_accessible collumns by default #864

Closed
kuraga opened this Issue Jun 26, 2012 · 3 comments

Projects

None yet

2 participants

@kuraga
kuraga commented Jun 26, 2012

All columns are rendered now if you call form.inputs. But only attr_accessible marked columns can be saved. What about a global configuration option or a method's option (with :role pointing?) that will be render columns from accessible_attributes' list?

@justinfrench
Owner

I disagree on attr_accessible — those columns can still be saved, they just can't be altered through mass assignment. I don't believe the model should know or be declaring what should be done in forms unless the information is there for another reason (like validations). I'm not keen on adding (or relying on anything existing) in ActiveModel for this.

This is a presentation issue, so it's view-side. We're already doing the right thing — we make a good guess by default, and provide a way to specify the set of fields to render. Really, the default option is there like scaffolding — it's fast to get started, but you're going to want control over the order of the fields, exactly which ones are rendered, how, etc.

form.inputs (without any options) is not intended for use in production code, but it can be handy in early stage development. Closing for now.

@kuraga
kuraga commented Jun 26, 2012

So is it a bad idea to store some information used by Formtastic in model?

@justinfrench
Owner

@kuraga I guess it depends, but in general, yes — the model should not be concerned with presentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment