sorta kinda works, but login/homepage are b0rked

This commit is contained in:
Skud
2013-02-01 11:10:12 +11:00
parent f25729ce3b
commit ed2e73832d
3 changed files with 9 additions and 6 deletions

View File

@@ -1,9 +1,15 @@
class ApplicationController < ActionController::Base
protect_from_forgery
load_and_authorize_resource
# tweak CanCan defaults because we don't have a "current_user" method
def current_ability
@current_ability ||= AccountAbility.new(current_member)
@current_ability ||= Ability.new(current_member)
end
# CanCan error handling
rescue_from CanCan::AccessDenied do |exception|
redirect_to root_url, :alert => exception.message
end
end

View File

@@ -1,4 +1,5 @@
class CropsController < ApplicationController
# GET /crops
# GET /crops.json
def index

View File

@@ -3,13 +3,11 @@ class Ability
def initialize(member)
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities
member ||= Member.new # guest member (not logged in)
# everyone can do these things, even non-logged in
can :read, :all
if member.logged_in?
if member
# managing your own user settings
can :update, Member, :id => member.id
@@ -36,8 +34,6 @@ class Ability
can :create, Planting
can :update, Planting, :garden => { :owner_id => member.id }
can :destroy, Planting, :garden => { :owner_id => member.id }
end
end
end