Rails: arel 基本用法

Equality

Greater than
Post.where(Post.arel_table[:published_at].gt(Time.current))
Post.where(Post.arel_table[:published_at].gteq(Time.current))
Less than or Less than or equal
Post.where(Post.arel_table[:published_at]).lt(Time.current))
Post.where(Post.arel_table[:published_at]).lteq(Time.current))
Not equal
Post.where(Post.arel_table[:title].not_eq('Master'))

Matching / (I)LIKE

Post.where(Post.arel_table[:title].matches('%Master%'))

Ordering

Post.order(Post.arel_table[:published_at].desc)

OR queries

Post.order(Post.arel_table[:title].eq('Master').or(Post.arel_table[:title].eq('Slave')))

AND queries

Post.order(Post.arel_table[:title].eq('Master').or(Post.arel_table[:published_at].gteq(Time.current)))