Sha256: 67ad5712aaf2915c3ebe8cf606b711269638b5448a7ca033eb36447fac4bb403

Contents?: true

Size: 992 Bytes

Versions: 1

Compression:

Stored size: 992 Bytes

Contents

class <%= user_plural_class_name %>Controller < ApplicationController

  before_filter :require_no_<%= user_singular_name %>, :only => [:new, :create]
  before_filter :require_<%= user_singular_name %>,    :only => [:show, :edit, :update]

  def new
    @<%= user_singular_name %> = <%= user_class_name %>.new
  end

  def create
    @<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
    if @<%= user_singular_name %>.save
      set_flash
      redirect_back_or_default <%= user_singular_name %>_url
    else
      render :new
    end
  end

  def show
    edit and render :edit
  end

  def edit
    @<%= user_singular_name %> = current_<%= user_singular_name %>
  end

  def update
    @<%= user_singular_name %> = current_<%= user_singular_name %>
    if @<%= user_singular_name %>.update_attributes(params[:<%= user_singular_name %>])
      set_flash
      redirect_to <%= user_singular_name %>_url
    else
      render :edit
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iain-pizza-generators-0.1.4 rails_generators/pizza_authentication/templates/users_controller.rb