Sha256: 4822de2cfe8ef0c2489b86def92975dba80ea28e9c2d5e6425c671d8690cfb22

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

class Forge::EventsController < ForgeController
  load_and_authorize_resource
  before_filter :uses_ckeditor, :only => [:edit, :update, :new, :create]

  def index
    respond_to do |format|
      format.html { @events = Event.paginate(:per_page => 10, :page => params[:page]) }
      format.js { 
        params[:q] ||= ''
        @events = Event.where("LOWER(title) LIKE ? OR LOWER(location) LIKE ? OR LOWER(description) LIKE ?", "%#{params[:q].downcase}%", "%#{params[:q].downcase}%", "%#{params[:q].downcase}%")
        render :partial => "event", :collection => @events
      }
    end
  end

  def new
    @event = Event.new
  end

  def edit
  end

  def create
    @event = Event.new(params[:event])
    if @event.save
      flash[:notice] = 'Event was successfully created.'
      redirect_to(forge_events_path)
    else
      render :action => "new"
    end
  end

  def update
    if @event.update_attributes(params[:event])
      flash[:notice] = 'Event was successfully updated.'
      redirect_to(forge_events_path)
    else
      render :action => "edit"
    end
  end

  def destroy
    @event.destroy
    redirect_to(forge_events_path)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
forge-cli-0.1.10 lib/forge/app/controllers/forge/events_controller.rb
forge-cli-0.1.9 lib/forge/app/controllers/forge/events_controller.rb
forge-cli-0.1.8 lib/forge/app/controllers/forge/events_controller.rb
forge-cli-0.1.7 lib/forge/app/controllers/forge/events_controller.rb
forge-cli-0.1.6 lib/forge/app/controllers/forge/events_controller.rb
forge-cli-0.1.5 lib/forge/app/controllers/forge/events_controller.rb