[code language=”ruby”]Article.joins(:comments).group("articles.id").order("max(comments.created_at) DESC")[/code]
You may also like
How to check if a hash’s all values are present ?
[code language=”ruby”] hash.all? { |k, v| v.present? } [/code]
How to do type cast in rails migration ?
[code language=”ruby”] class ChangePriceTypeInSales < ActiveRecord::Migration def change change_column :sales, :price, ‘float USING CAST(price AS float)’…
How to validate image type with modal validation ruby on rails ?
[code language=”ruby”] validates_format_of :image, :with => %r{.(png|jpg|jpeg)$}i, :message => "Please use image " [/code]
Recent Comments