Sha256: 301aea5732fdf5642343706d12f0be1c9b65a4f12e9ba50824ac11be8b638fc5
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
class User < ActiveRecord::Base include ActiveModel::Validations::Callbacks has_many :likes has_many :movies, through: :likes has_many :user_follows def likes?(movie) likes.where(movie_id: movie.id).exists? end def like!(movie) movies << movie unless likes?(movie) end def unlike!(movie) likes.where(movie_id: movie.id, user_id: self.id).destroy_all end include Neoid::Node neoidable do |c| c.field :name c.field :slug end end class Movie < ActiveRecord::Base include ActiveModel::Validations::Callbacks has_many :likes has_many :users, through: :likes include Neoid::Node neoidable do |c| c.field :name c.field :slug c.field :year c.search do |s| s.fulltext :name s.index :name s.index :slug s.index :year end end end class UserFollow < ActiveRecord::Base include ActiveModel::Validations::Callbacks belongs_to :user, dependent: :destroy belongs_to :item, polymorphic: true include Neoid::Relationship neoidable do |c| c.relationship start_node: :user, end_node: :item, type: :follows end end class Like < ActiveRecord::Base include ActiveModel::Validations::Callbacks belongs_to :user, dependent: :destroy belongs_to :movie, dependent: :destroy include Neoid::Relationship neoidable do |c| c.relationship start_node: :user, end_node: :movie, type: :likes c.field :rate end end class Article < ActiveRecord::Base include ActiveModel::Validations::Callbacks include Neoid::Node neoidable do |c| c.field :title c.field :year c.field :title_length do self.title ? self.title.length : 0 end c.search do |s| s.fulltext :title s.index :title s.index :body s.index :year end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
neoid-0.0.51 | spec/support/models.rb |
neoid-0.0.5.alpha | spec/support/models.rb |