Sha256: a79e296deac9e3e3109ad40b11510a0206031391e640daca046dce55e2476284

Contents?: true

Size: 1.34 KB

Versions: 15

Compression:

Stored size: 1.34 KB

Contents

class <%= controller_class_name %>Controller < ApplicationController

  def index
    @search = <%= "#{model_class_name}.search(params[:search])" %>
    <%= "@#{plural_model_name}" %> = @search.page(params[:page])
  end

  def new
    <%= "@#{singular_model_name}" %> = <%= "#{model_class_name}.new" %>
  end

  def create
    <%= "@#{singular_model_name}" %> = <%= "#{model_class_name}.new(params[:#{singular_model_name}])" %>
    
    if <%= "@#{singular_model_name}.save" %>
      flash[:notice] = '<%= human_name %> was successfully created.'
      redirect_to_ok_url_or_default :action => "index"
    else
      render :action => "new"
    end
  end

  def edit
    @<%= singular_model_name %> = <%= "#{model_class_name}.find(params[:id])" %>
  end

  def update
    <%= "@#{singular_model_name}" %> = <%= "#{model_class_name}.find(params[:id])" %>

    if <%= "@#{singular_model_name}.update_attributes(params[:#{singular_model_name}])" %>
      flash[:notice] = '<%= human_name %> was successfully updated.'
      redirect_to_ok_url_or_default :action => "index"
    else
      render :action => "edit"
    end
  end

  def destroy
    <%= "@#{singular_model_name}" %> = <%= "#{model_class_name}.find_by_id(params[:id])" %>
    <%= "@#{singular_model_name}.destroy" %> if @<%= singular_model_name %>
    
    redirect_to_ok_url_or_default :action => "index"
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
fume-0.10.0a lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.9.3 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.9.2 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.9.1 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.9.0 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.8.1a lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.8.0 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.8.0b lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.8.0a lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.7.2 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.7.1 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.7.0 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.6.7 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.6.6 lib/generators/fume/simple_scaffold/templates/controller.rb
fume-0.6.4 lib/generators/fume/simple_scaffold/templates/controller.rb