55 lines
1 KiB
Ruby
55 lines
1 KiB
Ruby
class UsersController < ApplicationController
|
|
def new
|
|
@user=User.new
|
|
end
|
|
|
|
def create
|
|
@user=User.new(user_params)
|
|
if @user.save
|
|
render 'show'
|
|
else
|
|
redirect_to new_user_path
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@user = User.find(params[:id])
|
|
end
|
|
|
|
def update
|
|
@user = User.find(params[:id])
|
|
attrs = user_params
|
|
respond_to do |format|
|
|
if @user.update(attrs)
|
|
flash[:notice] = 'Konto wurde erfolgreich aktualisiert.'
|
|
format.html { redirect_to user_url(@user) }
|
|
format.xml { head :ok }
|
|
else
|
|
format.html { render :action => "edit" }
|
|
format.xml { render :xml => @user.errors.to_xml }
|
|
end
|
|
end
|
|
end
|
|
|
|
def show
|
|
@user = User.find_by_id(params[:id])
|
|
end
|
|
|
|
def index
|
|
@users = User.all
|
|
end
|
|
|
|
def destroy
|
|
@user = User.find(params[:id])
|
|
@user.destroy
|
|
respond_to do |format|
|
|
format.html { redirect_to users_url }
|
|
format.xml { head :ok }
|
|
end
|
|
end
|
|
|
|
private
|
|
def user_params
|
|
params.require(:user).permit(:email, :password)
|
|
end
|
|
end
|