mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 13:38:24 -04:00
sorta kinda works, but login/homepage are b0rked
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class CropsController < ApplicationController
|
||||
|
||||
# GET /crops
|
||||
# GET /crops.json
|
||||
def index
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user