Sha256: f4a91baa80884730e70d783df1b482c631df203c3e17477df4fe7f3cf472ec05

Contents?: true

Size: 812 Bytes

Versions: 9

Compression:

Stored size: 812 Bytes

Contents

class ThingsController < ApplicationController
  before_filter :get_thing, :except => [:index, :new, :create]
  before_filter :get_new_thing, :only => [:new, :create]

  def index
    @things = Thing.all
  end

  def show
    if @thing.has_warning?
      Ominous::Warning.trigger(:thing_alert)
    end

  end


  def new

  end

  def edit
  end


  def create
    update_thing
  end

  def update
    update_thing
  end

  def destroy
    @thing.destroy
    redirect_to things_url
  end
  
  private
  def update_thing
    if @thing.update_attributes(params[:thing])
      redirect_to @thing, notice: "Thing was successfully #{action_name}d."
    else
      render action: "new"
    end
  end
  
  def get_thing
    @thing = Thing.find(params[:id])
  end
  
  def get_new_thing
    @thing = Thing.new
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ominous-0.1.3 test/dummy/app/controllers/things_controller.rb
ominous-0.1.2 test/dummy/app/controllers/things_controller.rb
ominous-0.1.1 test/dummy/app/controllers/things_controller.rb
ominous-0.1.0 test/dummy/app/controllers/things_controller.rb
ominous-0.0.5 test/dummy/app/controllers/things_controller.rb
ominous-0.0.4 test/dummy/app/controllers/things_controller.rb
ominous-0.0.3 test/dummy/app/controllers/things_controller.rb
ominous-0.0.2 test/dummy/app/controllers/things_controller.rb
ominous-0.0.1 test/dummy/app/controllers/things_controller.rb