Rails 4 - ActionMailer Send Shipping Confirmation Email -


i'm building marketplace app sellers can list items sell. i've set actionmailer send out order confirmation email triggered on order.save. i'm trying set shipping confirmation email, triggered when seller clicks on button indicate item has been shipped.

i'm getting stuck on data being passed through actionmailer. undefined method 'buyer' error on @order.buyer.email in mailer method below. how pass buyer info mailer?

i'd pass listing data mailer can use listing details in email content.

model info: have user model, listing model , order model. order model has buyer_id column foreign key user model , listing_id foriegn key listing model. users email stored in user model.

here code:

#route 'shipconf' => "orders#shipconf"  #order_controller def shipconf   autonotifier.shipconf_email(@order).deliver end  #autonotifier.rb def shipconf_email(order)    @order =  order    mail(to: @order.buyer.email, bcc: "ashfaaqmoosa@gmail.com", subject: 'you have new order @ outfit additions.') end  #sellers admin view table order info. seller clicks button send mail.   <% @orders.each |order| %>     <tr>       <td><%= order.id %></td>       <td><%= link_to order.listing.name.downcase.titleize, order.listing, data: { no_turbolink: true } %></td>       <td><%= number_to_currency(order.listing.price) %></td>       <td><%= order.shipaddress %></td>       <td><%= best_in_place order, :tracking, :type => :input, :url => listing_order_path(id: order.id, listing_id: order.listing_id) %> </td>       <td><%= link_to "send email", shipconf_path(order), class: "btn btn-sm btn-primary" %></td>     </tr>   <% end %>  #order model belongs_to :listing belongs_to :buyer, class_name: "user" belongs_to :seller, class_name: "user"  #user model has_many :listings, dependent: :destroy has_many :orders, class_name: "order", foreign_key: "seller_id" has_many :purchases, class_name: "order", foreign_key: "buyer_id"  #listing model belongs_to :user has_many :orders 

did define @order variable somewhere shipconf action?

if not have define it, example this:

#order_controller def shipconf   @order = order.find(params[:id])   autonotifier.shipconf_email(@order).deliver end 

and change link to:

shipconf_path(id: order.id) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -