Sha256: aaa3208daaf0c8452885e8c292cdd666ed1a7ddb2b28bb866ae676e6120ea4b3
Contents?: true
Size: 1.05 KB
Versions: 14
Compression:
Stored size: 1.05 KB
Contents
class TodoItem < ActiveRecord::Base def view_permitted?(attribute) !acting_user or user_is? acting_user end def update_permitted? return true unless acting_user return only_changed? :comments unless user_is? acting_user true end belongs_to :user has_many :comments has_many :commenters, class_name: "User", through: :comments, source: :user belongs_to :comment # just so we can test an empty belongs_to relationship scope :find_string, ->(s) { where("title LIKE ? OR description LIKE ?", "%#{s}%", "%#{s}%") } scope :active, -> { where("title LIKE '%mitch%' OR description LIKE '%mitch%'")} # to_sync :active do |scope, record| # if record.title =~ /mitch/ || record.description =~ /mitch/ # scope << record # else # scope.delete(record) # end # end scope :important, -> { where("title LIKE '%another%' OR description LIKE '%another%'")} # to_sync(:important) {title =~ /another/ || description =~ /another/ } def virtual_user_first_name user.first_name end unless RUBY_ENGINE == 'opal' end
Version data entries
14 entries across 7 versions & 1 rubygems