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

An example with nested attributes? #20

Open
nathanvda opened this issue Jul 11, 2014 · 1 comment
Open

An example with nested attributes? #20

nathanvda opened this issue Jul 11, 2014 · 1 comment

Comments

@nathanvda
Copy link

Hi, I am the author of the cocoon gem, and received a request to be able to create nested forms with ActiveModel models. This gems seems like the perfect answer from the short explanation in the readme, except I have no idea how you can implement two nested tableless models.

In the code I see no overruling of any association code (at first sight), so not sure it is actually supported at all. Also, while claims are made, I see no examples ;)

If you can provide me with a simple explanation, I am willing to play around myself, no need for big elaborate examples ;) If I can get it to work, I can update the README myself :)

@jarl-dk
Copy link
Member

jarl-dk commented Jul 11, 2014

On mt todo list I have an item syaing that I should demonstrate that in the cucumber tests...

However as it is now this feature is test in the specs:
https://github.com/softace/activerecord-tableless/blob/master/spec/lib/activerecord-tableless_spec.rb

I know this is not the optimal source of information, but I may help you until I find some time to do it.

In my own project I have file models/integration/ejddb/order.rb

require 'activerecord-tableless'
class Integration::Ejddb::Order < ActiveRecord::Base
  has_no_table
  has_many :files, :class_name => 'Integration::Ejddb::File', :foreign_key => 'order_id', :validate => false

file models/integration/ejddb/file.rb

require 'activerecord-tableless'
class Integration::Ejddb::File < ActiveRecord::Base
  has_no_table
  belongs_to :order, :class_name => 'Integration::Ejddb::Order', :foreign_key => 'order_id';

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