Fix bug preventing Platinum users from commenting.

Bug:

Platinum users get this error when commenting:

    No route matches {:action=>"show", :controller=>"posts", :id=>nil}
    missing required keys: [:id]

Fix:

The issue was that `CurrentUser.role` was nil for Platinum users, which
caused `Comment.create(create_params, :as => CurrentUser.role)` to
silently ignore the create_params because the nil role wasn't in the
attr_accessible whitelist.

Despite this, things worked accidentally for other models because they
had `attr_accessible ..., :as => [:default]` in their whitelists where
the comment model didn't.
This commit is contained in:
evazion
2016-12-29 15:45:23 -06:00
parent c0ae6e8631
commit d2e9ff363b

View File

@@ -369,6 +369,9 @@ class User < ActiveRecord::Base
when Levels::GOLD
:gold
when Levels::PLATINUM
:platinum
when Levels::BUILDER
:builder