Sha256: 43bee1879a862e363e72e9ca6da4755e5d18463615377e098a098ed268218d15
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
module ActsAsCommentableMore module Helpers module Post module AssociationsHelper private def post_define_role_based_inflection(role, association_comment_name) commantable_name = aacm_association_options[:as].to_sym send("define_role_based_inflection_#{Rails.version.first}", role, commantable_name, association_comment_name) end def define_role_based_inflection_3(role, commantable_name, association_comment_name) has_many "#{association_comment_name}".to_sym, has_many_options(role).merge(:conditions => { role: role }) end def define_role_based_inflection_4(role, commantable_name, association_comment_name) order_by_attrs = aacm_association_options[:order_by] has_many "#{association_comment_name}".to_sym, -> { includes(commantable_name, :user).where(role: role).order(order_by_attrs) }, has_many_options(role) end def has_many_options(role) association_options = aacm_association_options.except(:order_by) { before_add: Proc.new { |post, comment| comment.role = role } }.merge(association_options) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_commentable_more-1.2.10 | lib/acts_as_commentable_more/helpers/post/associations_helper.rb |