Sha256: 928080f866ca8996b027701c365125a09382eb448a19387f5564df7b775037dc

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

class Admin::OptionsController < Admin::BaseController
  
  def index
    list
    render :action => 'list'
  end  
  
  def new
    @option = Option.new
  end
  
  def list
    @options =  Option.find(:all, :page => {:size => 10, :current =>params[:page], :first => 1})
  end
  
  def create
    @option = Option.new(@params['option'])
    @option.option_values = OptionValue.find(params[:option_values]) if params[:option_values]
    @option.save!
    flash[:notice] = 'Option was successfully created.'
    redirect_to :action => 'index'    
  rescue
    logger.error("unable to create new option: #{@option.inspect}")
    flash[:notice] = 'ERROR - Problem saving new option'
    # error occurred while saving, give user a chance to save again
    render :action => 'new'
  end    
  
  def edit
    @option = Option.find(@params[:id])
  end
  
  def show
    @option = Option.find(@params[:id])
  end
  
  def update
    @option = Option.find(@params[:id])
    if @option.update_attributes(@params[:option])
      flash[:notice] = 'Option was successfully updated.'
      redirect_to :action => 'index', :id => @option
    else
      render :action => 'edit'
    end
  end
  
  def destroy
    Option.find(params[:id]).destroy
    redirect_to :action => 'index'
  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/options_controller.rb
railscart-0.0.2 starter_app/vendor/plugins/railscart/app/controllers/admin/options_controller.rb