Guest User

Untitled

a guest
Jan 17th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. def something
  2. @foo = Foo.find_by_guid(params[:id])
  3. unless @foo
  4. @msg ||= { :title => 'No such page!',
  5. :desc => "There is no such page!" }
  6. render :action => "error" and return
  7. end
  8. unless @foo.owner_id == current_user.id
  9. @msg ||= { :title => 'Really?',
  10. :desc => "There is no such page." }
  11. render :action => "error" and return
  12. end
  13.  
  14. class MegaController < ActionController::Base
  15. before_filter :grab_and_check_foo
  16. #...
  17. private
  18. def grab_and_check_foo
  19. @foo = Foo.find_by_guid(params[:id])
  20. if !@foo
  21. #... render some error stuff
  22. end
  23. if @foo.owner_id != current_user.id
  24. #... render some other error stuff
  25. end
  26. end
  27. end
Add Comment
Please, Sign In to add comment