ruby - Rails 4 Rescope or Refilter child object on the fly -
ruby - Rails 4 Rescope or Refilter child object on the fly -
there billingcycle:
class billingcycle     has_many :billing_data, class_name: billingdata     has_many :billing_data_lines, through: :billing_data end  class billingdata   has_many :billing_data_lines end    and here billingdataline:
class billingdataline    belongs_to :billing_data end    there place in code rescope or update list of kid records this:
@cycle.billing_data_lines = @cycle.billing_data_lines.where(info_number: @restricted_numbers)    but doesn't work , spits out error:
cannot modify association 'billingcycle#billing_data_lines' because source reflection class 'billingdataline' associated 'billingdata' via :has_many.    maybe i'm trying approach situation wrong way, nice if re-filter/re-scope kid object's records on fly. there way accomplish needed?
in class billingcycle refract class_name argument string:
class billingcycle   has_many :billing_data, class_name: "billingdata"    or remove it, cause doesn't create sense, since name same.
class billingcycle   has_many :billing_data        ruby-on-rails ruby activerecord 
 
Comments
Post a Comment