cancancan permissions
This commit is contained in:
parent
26f66f8bff
commit
b0fec45150
3 changed files with 10 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
||||||
class ProductsController < ApplicationController
|
class ProductsController < ApplicationController
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@product = Product.new
|
@product = Product.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
load_and_authorize_resource only: [:destroy]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
@orders = @user.orders.paginate(page: params[:page])
|
@orders = @user.orders.paginate(page: params[:page])
|
||||||
|
@ -17,7 +19,11 @@ class UsersController < ApplicationController
|
||||||
def dagschotel
|
def dagschotel
|
||||||
user = User.find(params[:user_id])
|
user = User.find(params[:user_id])
|
||||||
user.dagschotel = Product.find(params[:product_id])
|
user.dagschotel = Product.find(params[:product_id])
|
||||||
user.save
|
if user.save
|
||||||
|
flash[:success] = "Succesfully removed user"
|
||||||
|
else
|
||||||
|
flash[:error] = "Error updating dagschotel"
|
||||||
|
end
|
||||||
redirect_to edit_user_registration_path(user)
|
redirect_to edit_user_registration_path(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,7 @@ Rails.application.routes.draw do
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
||||||
resources :users do
|
resources :users do
|
||||||
resources :orders, only: [:new, :create, :index] do
|
resources :orders, only: [:new, :create, :index]
|
||||||
end
|
|
||||||
get 'quickpay' => 'orders#quickpay'
|
get 'quickpay' => 'orders#quickpay'
|
||||||
get 'dagschotel/:product_id' => 'users#dagschotel', as: "dagschotel"
|
get 'dagschotel/:product_id' => 'users#dagschotel', as: "dagschotel"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue