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

Does attributes order matter on creation? #25

Open
karellm opened this issue Jan 5, 2015 · 2 comments
Open

Does attributes order matter on creation? #25

karellm opened this issue Jan 5, 2015 · 2 comments

Comments

@karellm
Copy link

karellm commented Jan 5, 2015

Hi,

I'm a little confused with this bug. First some code:

class Company < ActiveRecord::Base
  acts_as :entity
  has_many :company_markets
  has_many :markets, through: :company_markets

  def market_ids
    # getter for market_ids
  end

  def market_ids=
    # setter for market_ids
  end
end

class Entity < ActiveRecord::Base
  # as a name attribute
  actable
end

I should also add I have a non-null constraint on the entity.name database table row.

Now the confusion:

Company.create(market_ids: [1, 2], name: 'test') will fail throwing PG::NotNullViolation: ERROR: null value in column "name" violates not-null constraint meaning the entity was created without the name I gave it.

But Company.create(name: 'test', market_ids: [1, 2]) will work. Huh?

So I was curious if that a normal behaviour or not. If not I could look at the code and do a PR. Let me know.

@hzamani
Copy link
Owner

hzamani commented Jan 6, 2015

It is a bug. And PR is welcome :-)

@karellm
Copy link
Author

karellm commented Jan 10, 2015

I have actually decided to change my DB design and won't need this gem anymore. So I won't work on the PR but will leave this open so you can address it eventually. Thanks for the good work. Cheers!

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

No branches or pull requests

2 participants