Guest User

Untitled

a guest
Jul 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. ## controller
  2. def update_macs
  3. begin
  4. @device = DeviceProcessor.process_device(params[:id])
  5. rescue Foo
  6. foo
  7. rescue Bar
  8. bar
  9. end
  10.  
  11. redirect_to :action => "show_device", :id => @device
  12. end
  13.  
  14. ## lib/device_processor.rb
  15. module DeviceProcessor
  16. def self.process_device(id)
  17. device = Device.find(id)
  18.  
  19. # shitloads of code here
  20.  
  21. device
  22. end
  23. end
  24.  
  25. ## lib/tasks/device_processor.rake
  26. # rake device_processor:process_device ID=6
  27. namespace :device_processor do
  28. task :process_device do
  29. DeviceProcessor.process_device(ENV["ID"])
  30. end
  31. end
Add Comment
Please, Sign In to add comment