Guest User

Untitled

a guest
Jan 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. ## ERROR
  2. TypeError in TasksController#index
  3.  
  4. can't dump anonymous class Class
  5.  
  6. app/controllers/tasks_controller.rb:26:in `block (2 levels) in check_email'
  7. app/controllers/tasks_controller.rb:24:in `each'
  8. app/controllers/tasks_controller.rb:24:in `block in check_email'
  9. app/controllers/tasks_controller.rb:22:in `check_email'
  10. app/controllers/tasks_controller.rb:7:in `index'
  11.  
  12.  
  13. ## MAILER
  14. require 'net/pop'
  15. class UserMailer < ActionMailer::Base
  16. def receive(email)
  17. task = Task.new(:name => email.subject, :description => email.body)
  18. end
  19. end
  20.  
  21. ## CONTROLLER
  22. require 'net/pop'
  23. class TasksController < ApplicationController
  24. def index
  25. check_email
  26. @tasks = Task.all
  27. respond_to do |format|
  28. format.html # index.html.erb
  29. format.xml { render :xml => @tasks }
  30. end
  31. end
  32.  
  33. def check_email
  34. pop_server = 'pop.gmail.com'
  35. pop_port = 995
  36. username = "###@gmail.com"
  37. password = "###"
  38.  
  39. Net::POP3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) #This line raises error if ruby version < 1.8.7
  40. Net::POP3.start(pop_server, pop_port, username, password) do |pop|
  41. unless pop.mails.empty?
  42. pop.mails.each do |email|
  43. task = UserMailer.receive(email.pop)
  44. task.save
  45. end
  46. end
  47. end
  48. end
  49.  
  50. def show
  51. @task = Task.find(params[:id])
  52.  
  53. respond_to do |format|
  54. format.html # show.html.erb
  55. format.xml { render :xml => @task }
  56. end
  57. end
  58. end
Add Comment
Please, Sign In to add comment