forked from wycats/jquery-governance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
motions_controller.rb
37 lines (30 loc) · 964 Bytes
/
motions_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class MotionsController < ApplicationController
before_filter :authenticate_member!, :except => [:index]
# List Motions that are open (NOT passed, failed, approved)
def index
@motions = Motion.open_state.order('created_at DESC').limit(6)
end
# List Motions that are closed (passed, failed, approved)
def closed
@motions = Motion.closed_state.order('created_at DESC').limit(6)
end
# Start a new Motion
def new
@motion = current_member.motions.build
end
# Show more records for the motion state section
def show_more
@motions = Motion.prev_with_same_state(params[:id]).order('created_at DESC').limit(6)
end
# Create a new Event
# @option params [Hash] :motion The new motion to create
def create
@motion = current_member.motions.build(params[:motion])
if @motion.save
flash[:notice] = "New motion was created successfully"
redirect_to root_url
else
render :new
end
end
end