Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def something
- @foo = Foo.find_by_guid(params[:id])
- unless @foo
- @msg ||= { :title => 'No such page!',
- :desc => "There is no such page!" }
- render :action => "error" and return
- end
- unless @foo.owner_id == current_user.id
- @msg ||= { :title => 'Really?',
- :desc => "There is no such page." }
- render :action => "error" and return
- end
- class MegaController < ActionController::Base
- before_filter :grab_and_check_foo
- #...
- private
- def grab_and_check_foo
- @foo = Foo.find_by_guid(params[:id])
- if !@foo
- #... render some error stuff
- end
- if @foo.owner_id != current_user.id
- #... render some other error stuff
- end
- end
- end
Add Comment
Please, Sign In to add comment