show error flash on failed file stuffs

This commit is contained in:
Felix Van der Jeugt 2016-02-04 23:47:34 +01:00
parent 9c31d9d6b4
commit 670b17622d
2 changed files with 5 additions and 7 deletions

View file

@ -5,17 +5,15 @@ class UsersController < ApplicationController
def show
end
def edit
end
def update
if @user.update_attributes(user_params)
flash[:success] = "Successfully updated!"
redirect_to @user
else
flash[:error] = "Update failed!"
# TODO form errors?
@user.reload
render 'edit'
end
redirect_to @user
end
def edit_dagschotel
@ -38,7 +36,7 @@ class UsersController < ApplicationController
private
def user_params
params.require(:user).permit(:avatar, :private, :dagschotel_id)
params.fetch(:user, {}).permit(:avatar, :private, :dagschotel_id)
end
def init

View file

@ -17,7 +17,7 @@ Rails.application.routes.draw do
end
end
resources :users, only: [:show] do
resources :users, only: [:show, :update] do
resources :orders, only: [:new, :create, :destroy]
member do
get 'quickpay' => 'users#quickpay'