You can define a method in the model Userthat replaces the argument :ordersthat you pass. This method should return paid orders.
Try using an association declaration (this will add you a method):
class User < ActiveRecord::Base
has_many :orders
has_many :paid_orders, class_name: 'Order', -> { where pay: true }
end
User paid_orders, orders, pay true.
:
option_groups_from_collection_for_select(User.order(:email), :paid_orders, :email, :id, :name)
.
, :paid_orders - User. , , :
class User < ActiveRecord::Base
has_many :orders
def paid_orders
orders.where pay: true
end
end