Sha256: 8b96e33d9f44922f5735e0ca8e6fdbd2599a644b9335a7c92a52ebb53f499b98

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

class <%= "#{@models}_controller".classify %> < ApplicationController
  skip_before_filter :require_login, :only => [:new, :create]
  # GET /users
  # GET /users.json
  def index
    @users = <%= @model.classify %>.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @users }
    end
  end

  # GET /users/1
  # GET /users/1.json
  def show
    @user = <%= @model.classify %>.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @user }
    end
  end

  # GET /users/new
  # GET /users/new.json
  def new
    @user = <%= @model.classify %>.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @user }
    end
  end

  # GET /users/1/edit
  def edit
    @user = <%= @model.classify %>.find(params[:id])
  end

  # POST /users
  # POST /users.json
  def create
    @user = <%= @model.classify %>.new(params[:<%= @model %>])
    if @user.save
      reset_session
      auto_login(@user) 
      redirect_to user_path(@user), notice: "Your Account has been created."
    else
      render action: "new" 
    end
  end

  # PUT /users/1
  # PUT /users/1.json
  def update
    @user = <%= @model.classify %>.find(params[:id])

    respond_to do |format|
      if @user.update_attributes(params[:<%= @model %>])
        format.html { redirect_to @user, notice: '<%= @model.classify %> was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @user.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /users/1
  # DELETE /users/1.json
  def destroy
    @user = <%= @model.classify %>.find(params[:id])
    @user.destroy

    respond_to do |format|
      format.html { redirect_to users_url }
      format.json { head :no_content }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bootup-0.0.4.1 lib/generators/bootup/templates/authentication/controllers/users_controller.rb.erb
bootup-0.0.4 lib/generators/bootup/templates/authentication/controllers/users_controller.rb.erb