Class: IshManager::EventsController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#create ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
|
# File 'app/controllers/ish_manager/events_controller.rb', line 4
def create
authorize! :manage, Ish::Event
@event = Ish::Event.create( params[:event].permit! )
if @event.persisted?
flash[:notice] = "Success."
redirect_to action: 'index'
else
flash[:alert] = "No luck: #{@event.errors.full_messages.join(', ')}."
render 'new'
end
end
|
#edit ⇒ Object
16
17
18
19
|
# File 'app/controllers/ish_manager/events_controller.rb', line 16
def edit
authorize! :manage, Ish::Event
@event = Ish::Event.find params[:id]
end
|
#index ⇒ Object
21
22
23
24
25
26
27
|
# File 'app/controllers/ish_manager/events_controller.rb', line 21
def index
authorize! :manage, Ish::Event
@events = Ish::Event.all.order_by({ start_at: :desc })
if params[:q]
@events = @events.where({ :name => /#{params[:q]}/i })
end
end
|
#new ⇒ Object
29
30
31
32
|
# File 'app/controllers/ish_manager/events_controller.rb', line 29
def new
authorize! :manage, Ish::Event
@event = Ish::Event.new
end
|
#show ⇒ Object
34
35
36
37
|
# File 'app/controllers/ish_manager/events_controller.rb', line 34
def show
authorize! :manage, Ish::Event
@event = Ish::Event.find params[:id]
end
|
#update ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/ish_manager/events_controller.rb', line 39
def update
authorize! :manage, Ish::Event
@event = Ish::Event.find params[:id]
@event.update_attributes( params[:event].permit! )
if @event.persisted?
flash[:notice] = "Success."
redirect_to action: 'index'
else
flash[:alert] = "No luck: #{@event.errors.full_messages.join(', ')}."
render 'edit'
end
end
|