Skip to content

Does the gem supports initialization of tableless model instance through association? #17

Description

@jibiel

Greetings.

Currently I'm trying to initialize object through has_one association like this:

class Report < ActiveRecord::Base
  has_no_table

  belongs_to :reportable, polymorphic: true

  column :reportable_id, :integer
  column :reportable_type, :string
  column :period, :daterange, 1.month.ago..Time.current

  attr_accessible :smth
end
class Store < ActiveRecord::Base
  has_one :report, as: :reportable

  # ...
end

But getting only:

> Store.take.build_report
  Store Load (0.6ms)  SELECT "stores".* FROM "stores" LIMIT 1
NoMethodError: undefined method `sanitize_limit' for #<Object:0x000001059b8ba0>
from /Users/jibiel/.rvm/gems/ruby-2.0.0-p451@smth/gems/activerecord-4.0.0/lib/active_record/relation/query_methods.rb:808:in `build_arel'

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions