Class: Forge::EventsController

Inherits:
ForgeController show all
Defined in:
lib/forge/app/controllers/forge/events_controller.rb

Instance Method Summary collapse

Methods inherited from ForgeController

#get_menu_items, #load_help, #set_crumbs, #set_title, #uses_ckeditor

Methods inherited from ApplicationController

#app_init

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
# File 'lib/forge/app/controllers/forge/events_controller.rb', line 23

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

#destroyObject



42
43
44
45
# File 'lib/forge/app/controllers/forge/events_controller.rb', line 42

def destroy
  @event.destroy
  redirect_to(forge_events_path)
end

#editObject



20
21
# File 'lib/forge/app/controllers/forge/events_controller.rb', line 20

def edit
end

#indexObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/forge/app/controllers/forge/events_controller.rb', line 5

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

#newObject



16
17
18
# File 'lib/forge/app/controllers/forge/events_controller.rb', line 16

def new
  @event = Event.new
end

#updateObject



33
34
35
36
37
38
39
40
# File 'lib/forge/app/controllers/forge/events_controller.rb', line 33

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