Sha256: 39d9ec65faea986db974b2243d49c1b3e38363b5ea788224688632db843e8fef

Contents?: true

Size: 1.58 KB

Versions: 60

Compression:

Stored size: 1.58 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 :back => '/app'
  end

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

  # GET /<%= class_name %>/new
  def new
    @<%= name.downcase %> = <%= class_name %>.new
    render :action => :new, :back => url_for(:action => :index)
  end

  # GET /<%= class_name %>/{1}/edit
  def edit
    @<%= name.downcase %> = <%= class_name %>.find(@params['id'])
    if @<%= name.downcase %>
      render :action => :edit, :back => url_for(:action => :index)
    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

60 entries across 60 versions & 2 rubygems

Version Path
rhodes-3.3.4 res/generators/templates/model/controller.rb
rhodes-3.3.3 res/generators/templates/model/controller.rb
rhodes-3.3.3.beta.4 res/generators/templates/model/controller.rb
rhodes-3.3.3.beta.3 res/generators/templates/model/controller.rb
rhodes-3.3.3.beta.2 res/generators/templates/model/controller.rb
rhodes-3.3.3.beta.1 res/generators/templates/model/controller.rb
rhodes-3.3.2 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.7 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.6 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.5 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.4 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.3 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.2 res/generators/templates/model/controller.rb
rhodes-3.3.2.beta.1 res/generators/templates/model/controller.rb
rhodes-3.3.1 res/generators/templates/model/controller.rb
rhodes-3.3.0 res/generators/templates/model/controller.rb
rhodes-3.3.0.beta.3 res/generators/templates/model/controller.rb
rhodes-3.3.0.beta.2 res/generators/templates/model/controller.rb
rhodes-3.3.0.beta.1 res/generators/templates/model/controller.rb
rhodes-3.2.3 res/generators/templates/model/controller.rb