lib/markable/acts_as_markable.rb in markable-0.1.2 vs lib/markable/acts_as_markable.rb in markable-0.1.3

- old
+ new

@@ -31,11 +31,11 @@ include Markable::ActsAsMarkable::MarkableInstanceMethods def self.marked_as(mark, options = {}) if options[:by].present? result = self.joins(:markable_marks).where( :marks => { - :mark => mark, :marker_id => options[:by].id, :marker_type => options[:by].class.name + :mark => mark.to_s, :marker_id => options[:by].id, :marker_type => options[:by].class.name }) markable = self result.class_eval do define_method :<< do |object| options[:by].set_mark mark, object @@ -45,11 +45,11 @@ options[:by].remove_mark mark, markable self end end else - result = self.joins(:markable_marks).where( :marks => { :mark => mark } ).group("#{self.table_name}.id") + result = self.joins(:markable_marks).where( :marks => { :mark => mark.to_s } ).group("#{self.table_name}.id") end result end end @@ -92,11 +92,11 @@ params = { :markable_id => self.id, :markable_type => self.class.name, :marker_id => marker.id, :marker_type => marker.class.name, - :mark => mark + :mark => mark.to_s } Markable::Mark.create(params) unless Markable::Mark.exists? params end end @@ -105,11 +105,11 @@ Markable.can_mark_or_raise? options[:by], self, mark end params = { :markable_id => self.id, :markable_type => self.class.name, - :mark => mark + :mark => mark.to_s } if options[:by].present? params[:marker_id] = options[:by].id params[:marker_type] = options[:by].class.name end @@ -123,26 +123,26 @@ params = { :markable_id => self.id, :markable_type => self.class.name, :marker_id => marker.id, :marker_type => marker.class.name, - :mark => mark + :mark => mark.to_s } Markable::Mark.delete_all(params) end else params = { :markable_id => self.id, :markable_type => self.class.name, - :mark => mark + :mark => mark.to_s } Markable::Mark.delete_all(params) end end def have_marked_as_by(mark, target) result = target.joins(:marker_marks).where( :marks => { - :mark => mark, :markable_id => self.id, :markable_type => self.class.name + :mark => mark.to_s, :markable_id => self.id, :markable_type => self.class.name }) markable = self result.class_eval do define_method :<< do |markers| Array.wrap(markers).each do |marker|