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

[Feature Request] Adding accepts_nested_attributes_for actable model #73

Open
brunzino opened this issue Mar 30, 2016 · 1 comment
Open

Comments

@brunzino
Copy link

I'm building a testing tool that gets, sets parameters for active_record resources, and it gets tripped up when working with my models that use active_record-acts_as. I was a little surprised to find that the parent object does not accept nested attributes for acts_as attributes. Example below

class NightReport < ActiveRecord::Base
  acts_as :report
  # with attribute :night_supervisor 
end

class Report < ActiveRecord::Base
  actable 
  # with attribute :date 
end

$ NightReport.new( {:night_supervisor => "Nick B", :report_attributes => { :date => Date.today } )
$ ActiveRecord::UnknownAttributeError: unknown attribute: report_attributes

I understand this capability is a little strange ("In which scenario would you want to send attributes with report_attributes => {} ?" ). Tough to explain briefly, but it has to do with the fact that the night_report.attributes list does not include report.attributes.

Are there any adverse effects to adding this capability?

I'd be happy to write up the specs, submit pull request myself.

Thanks for the gem!

-Nick

EDIT: removed section about it appearing to already accept nested attributes

@manuelmeurer
Copy link
Collaborator

Hi Nick,

Does this work?

class NightReport < ActiveRecord::Base
  acts_as :report 
  accepts_nested_attributes_for :report
end

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