我是StackOverFlow的新手。 见到你很高兴。
现在,我正在使用Spree Framework开发EC Rails应用程序。
Spree管理员角色用户一切正常。
但是自定义角色用户在TextEditor中修改源代码后会重定向到authentication_failure。
进程发生错误如下:
Admin
角色每次都没有问题。仅问题出现在自定义角色中。出现的错误是-
CanCan::AccessDenied error.
怎么了?
我阅读了文档和Gem代码,但我不知所措。
我的能力文件如下:
sub_admin_ability.rb
module Spree
class SubAdminAbility
include CanCan::Ability
def initialize(user)
user ||= Spree.user_class.new
if user.sub_admin?
can [:admin, :manage], Spree::Product
can [:admin, :manage], Spree::Address
can [:admin, :manage], Spree::Profile
can [:admin, :manage], Spree::Image
can [:admin, :create, :update, :addresses], Spree::User
end
end
end
end
我使用的是宝石版本:
谢谢!
*添加sign_out日志
Started GET "/logout" for xxx.xx.xx.xx at 2019-02-20 15:01:43 +0900
Cannot render console from xxx.xx.xx.xx! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Spree::UserSessionsController#destroy as HTML
Spree::User Load (0.6ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."deleted_at" IS NULL AND "spree_users"."id" = $1 ORDER BY "spree_users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]]
Spree::Preference Load (0.4ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT $2 [["key", "spree/app_configuration/currency"], ["LIMIT", 1]]
Spree::Store Load (0.5ms) SELECT "spree_stores".* FROM "spree_stores" WHERE (url like '%localhost%') ORDER BY "spree_stores"."id" ASC LIMIT $1 [["LIMIT", 1]]
Spree::Order Load (0.6ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."store_id" = $3 LIMIT $4 [["currency", "JPY"], ["guest_token", "dAvpS_lrpvdlbOxY2W6_RA1550053840935"], ["store_id", 1], ["LIMIT", 1]]
Spree::Order Load (0.6ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL ORDER BY created_at DESC LIMIT $2 [["user_id", 1], ["LIMIT", 1]]
Spree::LineItem Load (0.5ms) SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" = 27 ORDER BY "spree_line_items"."created_at" ASC
Spree::Variant Load (0.5ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_variants"."id" = 8
Spree::Image Load (0.5ms) SELECT "spree_assets".* FROM "spree_assets" WHERE "spree_assets"."type" IN ('Spree::Image') AND "spree_assets"."viewable_type" = $1 AND "spree_assets"."viewable_id" = 8 ORDER BY "spree_assets"."position" ASC [["viewable_type", "Spree::Variant"]]
Spree::OptionValueVariant Load (0.4ms) SELECT "spree_option_value_variants".* FROM "spree_option_value_variants" WHERE "spree_option_value_variants"."variant_id" = 8
Spree::OptionValue Load (0.4ms) SELECT "spree_option_values".* FROM "spree_option_values" WHERE "spree_option_values"."id" = 2
Spree::Product Load (0.7ms) SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."deleted_at" IS NULL AND "spree_products"."id" = 5
Spree::Order Load (0.6ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL AND (id != 27) [["user_id", 1]]
(0.3ms) BEGIN
(0.3ms) COMMIT
Redirected to http://localhost:3000/
Completed 302 Found in 36ms (ActiveRecord: 6.9ms)