Sha256: 0de66ff9d95f099a265f875c1706d7e32587a18c6fce147a78052c096433b55c

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

class Admin::OptionValuesController < Admin::BaseController
  
  def index
    list
    render :action => 'list'
  end  
  
  def list
    @option_values =  OptionValue.find(:all, :page => {:size => 10, :current =>params[:page], :first => 1})
  end

  def create
	@option_value = OptionValue.new(@params['option_value'])
    @option_value.save!
    flash[:notice] = 'Option value was successfully created.'
    redirect_to :action => 'list'    
  rescue
    logger.error("unable to create new option value: #{@option_value.inspect}")
    flash[:error] = ' Problem saving new option value'
    # error occurred while saving, give user a chance to save again
    render :action => 'new'
  end    

  def edit
    @option_value = OptionValue.find(@params[:id])
  end
  
  def update
    @option_value = OptionValue.find(@params[:id])
    if @option_value.update_attributes(@params[:option_value])
      flash[:notice] = 'Option value was successfully updated.'
      redirect_to :action => 'list'
    else
      render :action => 'list'
    end
  end
  
  def destroy
    OptionValue.find(params[:id]).destroy
    redirect_to :action => 'list'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
railscart-0.0.1 starter-app/vendor/plugins/railscart/app/controllers/admin/option_values_controller.rb
railscart-0.0.2 starter_app/vendor/plugins/railscart/app/controllers/admin/option_values_controller.rb