Sha256: e95e7ea51c026bce5aa9d144512be97ac4cc1669d01672776601a62617f0828e

Contents?: true

Size: 1.48 KB

Versions: 15

Compression:

Stored size: 1.48 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 %>.new(@params['<%= name.downcase %>'])
    @<%= name.downcase %>.save
    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

15 entries across 15 versions & 1 rubygems

Version Path
rhodes-2.0.3 res/generators/templates/model/controller.rb
rhodes-2.0.2 res/generators/templates/model/controller.rb
rhodes-2.0.0 res/generators/templates/model/controller.rb
rhodes-2.0.0.rc2 res/generators/templates/model/controller.rb
rhodes-2.0.0.rc1 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta11 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta10 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta9 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta8 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta7 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta6 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta4 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta3 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta2 res/generators/templates/model/controller.rb
rhodes-2.0.0.beta1 res/generators/templates/model/controller.rb