Answers for "rails scopes"

1

rails scopes

class Book < ApplicationRecord
  scope :costs_more_than, ->(amount) { where("price > ?", amount) }
end
Posted by: Guest on April-21-2021
0

how to write a scope in rails

scope :proponent,   ->(user){ where(user_id: user.id) }
Posted by: Guest on August-12-2021

Browse Popular Code Answers by Language