Sha256: 8a6d89d4896f721f97208d7a66516109714d79414940a541438888867ef004e9

Contents?: true

Size: 1.46 KB

Versions: 28

Compression:

Stored size: 1.46 KB

Contents

require 'rho/rhocontroller'
require 'helpers/browser_helper'

class <%= class_name %>Controller < Rho::RhoController
  include BrowserHelper

  #GET /<%= class_name %>
  def index
    @<%= name.downcase.pluralize %> = <%= class_name %>.find(:all)
    render
  end

  # GET /<%= class_name %>/{1}
  def show
    @<%= name.downcase %> = <%= class_name %>.find(@params['id'])
    if @<%= name.downcase %>
      render :action => :show
    else
      redirect :action => :index
    end
  end

  # GET /<%= class_name %>/new
  def new
    @<%= name.downcase %> = <%= class_name %>.new
    render :action => :new
  end

  # GET /<%= class_name %>/{1}/edit
  def edit
    @<%= name.downcase %> = <%= class_name %>.find(@params['id'])
    if @<%= name.downcase %>
      render :action => :edit
    else
      redirect :action => :index
    end
  end

  # POST /<%= class_name %>/create
  def create
    @<%= name.downcase %> = <%= class_name %>.create(@params['<%= name.downcase %>'])
    redirect :action => :index
  end

  # POST /<%= class_name %>/{1}/update
  def update
    @<%= name.downcase %> = <%= class_name %>.find(@params['id'])
    @<%= name.downcase %>.update_attributes(@params['<%= name.downcase %>']) if @<%= name.downcase %>
    redirect :action => :index
  end

  # POST /<%= class_name %>/{1}/delete
  def delete
    @<%= name.downcase %> = <%= class_name %>.find(@params['id'])
    @<%= name.downcase %>.destroy if @<%= name.downcase %>
    redirect :action => :index
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
rhodes-2.3.2 res/generators/templates/model/controller.rb
rhodes-2.3.2.beta.2 res/generators/templates/model/controller.rb
rhodes-2.3.2.beta.1 res/generators/templates/model/controller.rb
rhodes-2.3.1 res/generators/templates/model/controller.rb
rhodes-2.3.1.beta.1 res/generators/templates/model/controller.rb
rhodes-2.3.0 res/generators/templates/model/controller.rb
rhodes-2.3.0.beta.3 res/generators/templates/model/controller.rb
rhodes-2.3.0.beta.2 res/generators/templates/model/controller.rb
rhodes-2.3.0.beta.1 res/generators/templates/model/controller.rb
rhodes-2.2.6 res/generators/templates/model/controller.rb
rhodes-2.2.6.beta.1 res/generators/templates/model/controller.rb
rhodes-2.2.5 res/generators/templates/model/controller.rb
rhodes-2.2.5.beta.3 res/generators/templates/model/controller.rb
rhodes-2.2.5.beta.2 res/generators/templates/model/controller.rb
rhodes-2.2.5.beta.1 res/generators/templates/model/controller.rb
rhodes-2.2.4.beta.1 res/generators/templates/model/controller.rb
rhodes-2.2.3 res/generators/templates/model/controller.rb
rhodes-2.2.3.beta.1 res/generators/templates/model/controller.rb
rhodes-2.2.2 res/generators/templates/model/controller.rb
rhodes-2.2.2.beta.1 res/generators/templates/model/controller.rb