app/controllers/application_controller.rb
# Takes any object that has a user method and checks against current_user
#TODO: This is mixing model logic!!!
Takes any object that has a user method and checks against current_user
TODO: This is mixing model logic
Takes any object that has a user method and checks against current_user TODO : This is mixing model logic
def user_is_owner_of(thing)
    unless current_user.is_owner_of?(thing)
      error_message = "You are not the owner of this #{thing.class.name.decamelize}."
      respond_to do |format|
        format.html do
          flash[:error] = error_message
          redirect_to access_denied_path and return false
        end
        format.js do
          render :update do |page|
            ajax_alert(page, "<strong>error:</strong> "+error_message);
          end
          return false
        end
      end
    end
    return true
  end
def user_is_owner_of ( thing ) unless current_user . is_owner_of? ( thing ) error_message = "You are not the owner of this #{thing.class.name.decamelize}." respond_to do | format | format . html do flash [ :error ] = error_message redirect_to access_denied_path and return false end format . js do render :update do | page | ajax_alert ( page , "<strong>error:</strong> " + error_message ) ; end return false end end end return true end
Takes any object that has a user method and checks against current_user
TODO: This is mixing model logic!!
Takes any object that has a user method and checks against current_user TODO : This is mixing model logic!!
# display alert
thing