Class: Admin::GoalsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/admin/goals_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/admin/goals_controller.rb', line 21

def create
  @goal = Goal.new(params[:goal])
  @goal.system_id = _sid
  @goal.user_id = current_user.id

  if @goal.save
    redirect_to [:admin, @goal], :notice => "Successfully created Goal" and return
    logger.debug "x"
  else
    render :action => 'new' 
    logger.debug "y"
  end
end

#destroyObject



48
49
50
51
52
# File 'app/controllers/admin/goals_controller.rb', line 48

def destroy
  @goal = Goal.find_sys_id(_sid, params[:id])
  @goal.destroy
  redirect_to admin_goals_url, :notice => "Successfully destroyed Goal"
end

#editObject



35
36
37
# File 'app/controllers/admin/goals_controller.rb', line 35

def edit
  @goal = Goal.find_sys_id(_sid,params[:id])
end

#indexObject



9
10
11
# File 'app/controllers/admin/goals_controller.rb', line 9

def index
  @goals = Goal.sys(_sid).all
end

#newObject



17
18
19
# File 'app/controllers/admin/goals_controller.rb', line 17

def new
  @goal = Goal.new
end

#scoresObject



3
4
5
6
7
# File 'app/controllers/admin/goals_controller.rb', line 3

def scores
  @goal = Goal.sys(_sid).where(:id=>params[:id]).first
  @scores = @goal.goals_users.includes(:user).page(params[:page]).per(100)

end

#showObject



13
14
15
# File 'app/controllers/admin/goals_controller.rb', line 13

def show
  @goal = Goal.find_sys_id(_sid, params[:id])
end

#updateObject



39
40
41
42
43
44
45
46
# File 'app/controllers/admin/goals_controller.rb', line 39

def update
  @goal = Goal.find_sys_id(_sid,params[:id])
  if @goal.update_attributes(params[:goal])
    redirect_to [:admin, @goal], :notice  => "Successfully updated Goal"
  else
    render :action => 'edit'
  end
end