-
Notifications
You must be signed in to change notification settings - Fork 41
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 the gem supports initialization of tableless model instance through association? #17
Comments
I'll take a look at it... |
This interests me too, did you find anything? |
Sorry guys... I have been busy. I'll see if I can find some time... |
@jarl-dk Ok, here's the new model: class Reportable < ActiveRecord::Base
has_no_table
has_one :report, as: :reportable
column :smth, :string
end The other two are still the same (though I've added polymorphic association, just ignore that). Here's what we have: > Store.take.build_report # Store «has_table»
Store Load (0.6ms) SELECT "stores".* FROM "stores" LIMIT 1
NoMethodError: undefined method `sanitize_limit' for #<Object:0x007fd5b9838560>
from /Users/jibiel/.rvm/gems/ruby-2.0.0-p481@smth/gems/activerecord-4.0.0/lib/active_record/relation/query_methods.rb:808:in `build_arel' > Store.new.build_report # Store «has_table»
=> #<Report reportable_id: nil, reportable_type: "Store", period: Sun, 01 Jun 2014 21:18:39 MSK +04:00..Tue, 01 Jul 2014 21:18:39 MSK +04:00> > Reportable.take # Reportable has_no_table
NoMethodError: undefined method `sanitize_limit' for #<Object:0x007fd5b98f0ed0>
from /Users/jibiel/.rvm/gems/ruby-2.0.0-p481@smth/gems/activerecord-4.0.0/lib/active_record/relation/query_methods.rb:808:in `build_arel' > Reportable.new.build_report # Reportable has_no_table
=> #<Report reportable_id: nil, reportable_type: "Reportable", period: Sun, 01 Jun 2014 21:18:39 MSK +04:00..Tue, 01 Jul 2014 21:18:39 MSK +04:00> That is nothing new. I mean, I can't |
I suppose, that is not a big deal if I'm the only one concerning. I imagine that the concept is difficult enough without the thing I'm asking. Meanwhile, we use simple workaround at the office: class Store < ActiveRecord::Base
# ...
def report
Report.new reportable: self
end
end > Store.take.report # Store «has_table»
Store Load (0.6ms) SELECT "stores".* FROM "stores" LIMIT 1
=> #<Report reportable_id: 321, reportable_type: "Store", period: Sun, 01 Jun 2014 21:31:35 MSK +04:00..Tue, 01 Jul 2014 21:31:35 MSK +04:00> |
…ough an association, it was throwing a 'NoMethodError: undefined method `sanitize_limit' for #<Object:...>". Fixed the error by defining that method on the "connection" variable. Took the method from the ActiveRecord gem: /lib/active_record/connection_adapters/abstract/database_statements.rb .
I have created a PR #24 which fixes this issue for me. Not heavily tested, though. |
…ough an association, it was throwing a 'NoMethodError: undefined method `sanitize_limit' for #<Object:...>". Fixed the error by defining that method on the "connection" variable. Took the method from the ActiveRecord gem: /lib/active_record/connection_adapters/abstract/database_statements.rb .
…mit' for #<Object:...>
@jarl-dk |
@jarl-dk I find myself reaching for this gem on most projects as well. Please ask for help maintaining if you are no longer able to do it effectively. I also need to understand how to build associations to |
… association, it was throwing a 'NoMethodError: undefined method `sanitize_limit' for #<Object:...>". Fixed the error by defining that method on the "connection" variable. Took the method from the ActiveRecord gem: /lib/active_record/connection_adapters/abstract/database_statements.rb .
Greetings.
Currently I'm trying to initialize object through
has_one
association like this:But getting only:
Is this currently supported? Could you please provide an example?
I suspect this is rather me not understanding things than lack of implementation.
Anyways, it'll be great to see such example in the
README.md
.Thanks.
The text was updated successfully, but these errors were encountered: