Sha256: 2fafc03ff4dd0e9143c470225d5223cb1a11464babc477bce595fcd4f840c5f8
Contents?: true
Size: 1.67 KB
Versions: 15
Compression:
Stored size: 1.67 KB
Contents
class UsersController < ApplicationController before_action :set_user, only: [:show, :edit, :update, :destroy] # --- # Tests for EitilWrapper::Decorator before_action :set_user, only: [:decorator_a, :decorator_b, :decorator_c, :decorator_d] # default def decorator_a hash = decorate(@user) render json: hash end # specific dec_method def decorator_b hash = decorate(@user, dec_method: :first_and_last_name) render json: hash end # post request, with 'isWeb' and 'isMobile' params def decorator_c hash = decorate(@user) render json: hash end # specific dec_class def decorator_d hash = decorate(@user, dec_class: :Application, dec_method: :timestamps) render json: hash end # --- # GET /users def index @users = User.all end # GET /users/1 def show end # GET /users/new def new @user = User.new end # GET /users/1/edit def edit end # POST /users def create @user = User.new(user_params) if @user.save redirect_to @user, notice: 'User was successfully created.' else render :new end end # PATCH/PUT /users/1 def update if @user.update(user_params) redirect_to @user, notice: 'User was successfully updated.' else render :edit end end # DELETE /users/1 def destroy @user.destroy redirect_to users_url, notice: 'User was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_user @user = User.find(params[:id]) end # Only allow a list of trusted parameters through. def user_params params.fetch(:user, {}) end end
Version data entries
15 entries across 15 versions & 1 rubygems