Tag: 移动性

无法使用Mobility通过Rails中的已翻译列进行排序

此问题基于发布到Mobility GitHub项目的问题。 上下文 Rails :5.0.6 流动性 :0.4.2(带表后端) 我正在使用支持多种文章类型的文章表(例如,博客文章,案例研究,知识库文章)。 此表包含一个列,用于跟踪查看文章的次数 – 一个整数列,每次为文章调用show动作时该列都会递增。 在实现这些文章的翻译时,我想单独跟踪每个翻译的视图数,而不是主文章对象。 为了实现这一点,我将views属性包含在我的对象的翻译属性之一: class Article [:title, :subtitle, :body] has_and_belongs_to_many :products attachment :hero_image, content_type: %w(image/jpeg image/png image/gif) validates :title, :body, :posted_on, presence: true scope :current, -> { where ‘posted_on { where type: [‘BlogPost’, ‘CaseStudy’] } def log_view(by = 1) self.views ||= 0 self.views += by self.save(touch: […]