You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because Inform defaults the attributes to nil, we are unable to selectively update attributes. i.e. you must pass in all of the attributes on the model.
e.g.
class PersonForm
include Inflorm
attribute :name
attribute :age
attribute :gender
end
So when you do a Person#update_attributes in your #persist! method, it overwrites the existing name and gender attributes to null. This is problematic, especially if you have non-null constraints on your database.
The text was updated successfully, but these errors were encountered:
What's the use-case? I don't think inflorm is really required if you're just updating one attribute.
Having said that I've been thinking about this from a patch perspective also, and I think it makes sense to be able to selectively update attributes. The only thing is that inflorm doesn't directly map to a single model. The whole point of it is to define your pubic API and validations completely separately from the models, so I'm wondering how you'd actually do this.
Ya I know the general use case, I was wondering if there's something specific in our app requiring it. For now I'd suggest ya that we have specific endpoints for one-off modifications (ie 'publish/unpublish') that could use slimmed down forms
Because Inform defaults the attributes to
nil
, we are unable to selectively update attributes. i.e. you must pass in all of the attributes on the model.e.g.
PersonForm.new(age: 27).to_h #=> {name: nil, age: 27, gender: nil}
So when you do a
Person#update_attributes
in your#persist!
method, it overwrites the existingname
andgender
attributes to null. This is problematic, especially if you have non-null constraints on your database.The text was updated successfully, but these errors were encountered: