Notes posted by hosh
RSS feed
hosh -
December 2, 2015
0 thanks
Not quite opposite of new_record?
new_record? will not check if the record has been destroyed
hosh -
December 2, 2015
1 thank
Not quite opposite of persisted?
persisted? will also check if the record has not been destroyed
hosh -
August 25, 2015
0 thanks
Using Arel
You can also use Arel.
For example:
class ArticlePage < ActiveRecord::Base belongs_to :article scope :published, -> { where.not(published_at: nil) } scope :all_ready, -> { select("every(workflow_state = 'ready') AS is_ready") } end class Article < ActiveRecord::Base has_many :article_pages def all_ready? ActiveRecord::Base.select_values(article_pages.all_ready,published) = 't' end end