Sha256: 863f0f7c26fa5b160442b7656b7c0ebf38984058392bf18174036364a2a702fa
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
module ActsAsCommentableMore module Helpers module Post module AssociationsHelper private def post_define_based_inflection(association_comment_name) commantable_name = aacm_association_options[:as].to_sym send("define_based_inflection_#{Rails.version.first}", commantable_name, association_comment_name) end def define_based_inflection_4(commantable_name, association_comment_name) order_by_attrs = aacm_association_options[:order_by] association_options = aacm_association_options.except(:order_by) has_many "#{association_comment_name}".to_sym, -> { order(order_by_attrs) }, association_options end ##========================== ##========================== 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, -> { 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.11 | lib/acts_as_commentable_more/helpers/post/associations_helper.rb |