cancancan permissions

This commit is contained in:
Benjamin Cousaert 2014-12-17 07:31:51 +01:00
parent 26f66f8bff
commit b0fec45150
3 changed files with 10 additions and 3 deletions

View file

@ -1,4 +1,6 @@
class ProductsController < ApplicationController
load_and_authorize_resource
def new
@product = Product.new
end

View file

@ -1,4 +1,6 @@
class UsersController < ApplicationController
load_and_authorize_resource only: [:destroy]
def show
@user = User.find(params[:id])
@orders = @user.orders.paginate(page: params[:page])
@ -17,7 +19,11 @@ class UsersController < ApplicationController
def dagschotel
user = User.find(params[:user_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)
end
end

View file

@ -5,8 +5,7 @@ Rails.application.routes.draw do
devise_for :users
resources :users do
resources :orders, only: [:new, :create, :index] do
end
resources :orders, only: [:new, :create, :index]
get 'quickpay' => 'orders#quickpay'
get 'dagschotel/:product_id' => 'users#dagschotel', as: "dagschotel"
end