samedi 4 mars 2017

Rails how get foreign_key on a mailer?

On a order confirmation both the seller and the user receive the confirmation but after add the seller_id or buyer_id rails spits out error!

i'm looking to suer where as a solution but did not find the specific ID

someone have a idea how to pass the foreign_key on a mailer?

thank's

class Order < ActiveRecord::Base


  belongs_to :seller, foreign_key: 'seller_id', class_name: 'Shop'
  belongs_to :buyer, foreign_key: 'buyer_id', class_name: 'User'

end





 def order_confirmation(order)

    @order = order
   @buyer = Order.where('buyer_id')
    mail(to: @buyer.email, subject: 'confirmation', &:html)
  end

 def order_confirmation_seller(order)
    @order = order
     @seller = Order.where('seller_id')
    mail(to: @seller.email, subject: 'confirmation', &:html)
  end

Aucun commentaire:

Enregistrer un commentaire