Skip to content

Commit

Permalink
Fixed bug with abilities for anonymous users
Browse files Browse the repository at this point in the history
  • Loading branch information
nerakdon committed Apr 6, 2017
1 parent d2b36e7 commit b09ca96
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/models/paid_up/ability.rb
Expand Up @@ -14,9 +14,12 @@ def initialize_paid_up(user)

private

def enable_rows(model, allowed, remaining)
def enable_read(model)
can :index, model
can :show, model, &:enabled?
end

def enable_rows(model, allowed, remaining)
if allowed.positive?
can :own, model
cannot :create, model
Expand All @@ -27,9 +30,10 @@ def enable_rows(model, allowed, remaining)
end

def enable_table_rows(user, feature)
model = feature.feature_model
enable_read(model)
return if user.new_record?
slug = feature.slug
model = feature.feature_model
table_setting = user.table_setting(slug)
allowed = table_setting.rows_allowed
remaining = table_setting.rows_remaining
Expand All @@ -38,9 +42,10 @@ def enable_table_rows(user, feature)
end

def enable_rolify_rows(user, feature)
model = feature.feature_model
enable_read(model)
return if user.new_record?
slug = feature.slug
model = feature.feature_model
rolify_setting = user.rolify_setting(slug)
allowed = rolify_setting.rows_allowed
remaining = rolify_setting.rows_remaining
Expand Down
Binary file modified spec/dummy/db/test.sqlite3
Binary file not shown.

0 comments on commit b09ca96

Please sign in to comment.