Guest User

Untitled

a guest
Aug 20th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. Rails 3.1 action mailer useage
  2. <tr id=<%= dom_id(blast)%> class="blast">
  3. <td><%= blast.id %></td>
  4. <td><%= blast.description %></td>
  5. <td><%= blast.subject %></td>
  6. <td><%= blast.last_sent %></td>
  7. <td><%= blast.created_at.strftime('%D at %I:%M %p') %></td>
  8. <td><%= link_to "Destroy", blast,:remote => true, :confirm => "Are You Sure?", :method => :delete %></td>
  9. <td><%= link_to "Edit",edit_blast_path(blast), :remote => true, :action => "edit"%></td>
  10. <td><%= link_to "Mail",blast, :action => 'show', :remote => true%></td>
  11.  
  12. class BlastsController < ApplicationController
  13. before_filter :require_user
  14. respond_to :html, :js
  15. def index
  16. @blasts = Blast.page(params[:page]).per(10)
  17.  
  18. end
  19.  
  20. def show
  21. @customer = Customer.all
  22. @blast = Blast.find(params[:id])
  23. end
  24.  
  25. def create
  26. @blast = Blast.new(params[:blast])
  27.  
  28. if @blast.save
  29. respond_with @blast, :location => blasts_url
  30.  
  31. end
  32. end
  33.  
  34. def destroy
  35. @blast = Blast.find(params[:id])
  36. @blast.destroy
  37.  
  38. respond_with @blast, :location => blasts_url
  39. end
  40.  
  41. def edit
  42. @blast = Blast.find(params[:id])
  43. respond_with @blast, :location => blasts_url
  44. end
  45.  
  46. def update
  47. @blast = Blast.find(params[:id])
  48. @blast.update_attributes(params[:blast])
  49.  
  50. respond_with @blast, :location => blasts_url
  51. end
  52. end
  53.  
  54. class BlastMailer < ActionMailer::Base
  55. default from: "info@ratatouillecatering.com"
  56.  
  57. def mail_blast(customer, blast)
  58. @customer = customer
  59. @blast=blast
  60. @customer.each do |f|
  61. mail(:to => f.email, :subject => "hello")
  62. end
  63. end
  64. end
Add Comment
Please, Sign In to add comment