Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle has one and accepts nil value for it #301

Closed
wants to merge 8 commits into from

Conversation

pisaruk
Copy link

@pisaruk pisaruk commented Nov 17, 2014

Now has_one associations will be taken into account when calling to_params in the parent model.
That allow us to save a parent model containing has_one associations.
For example:

class Person
  include Her::Model
  has_one :nick_name
  attributes :name
end

class NickName
  include Her::Model
  attributes :origin, :author, :created_at
end

p = Person.first
p.assign_attributes(name: 'José', 
  nick_name_attributes: {origin: 'high_school', author: 'Big Guy', created_at: 18.years.ago})
p.save

Besides that nil value will be accepted:

p = Person.first
p.nick_name = nil
p.save

@diegoy
Copy link

diegoy commented Jan 23, 2015

This feature is useful, is there any problem in this implementation in particular?

@hubert
Copy link
Contributor

hubert commented Aug 18, 2015

most of the code here is PRd in #262 which i've responded to the OP about. going to close this for now and wait for a few small changes before we try to merge it.

thanks for contributing!

@hubert hubert closed this Aug 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants