Class: Triumph::AchievementsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Triumph::AchievementsController
- Defined in:
- app/controllers/triumph/achievements_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /achievements POST /achievements.xml.
-
#destroy ⇒ Object
DELETE /achievements/1 DELETE /achievements/1.xml.
-
#edit ⇒ Object
GET /achievements/1/edit.
-
#index ⇒ Object
GET /achievements GET /achievements.xml.
-
#new ⇒ Object
GET /achievements/new GET /achievements/new.xml.
-
#show ⇒ Object
GET /achievements/1 GET /achievements/1.xml.
-
#update ⇒ Object
PUT /achievements/1 PUT /achievements/1.xml.
Instance Method Details
#create ⇒ Object
POST /achievements POST /achievements.xml
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/triumph/achievements_controller.rb', line 44 def create @achievement = Achievement.new(params[:triumph_achievement]) @achievement.observe_class.downcase! if @achievement.save achievement_condition = AchievementCondition.new(params[:achievement_condition]) achievement_condition.achievement_id = @achievement.id if achievement_condition.save redirect_to(@achievement, :notice => 'Achievement was successfully created.') else flash[:error] = "Failed to save achievement conditions" end else render :action => "new" end end |
#destroy ⇒ Object
DELETE /achievements/1 DELETE /achievements/1.xml
80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/triumph/achievements_controller.rb', line 80 def destroy @achievement = Achievement.find(params[:id]) @achievement.destroy respond_to do |format| format.html { redirect_to(triumph_achievements_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /achievements/1/edit
38 39 40 |
# File 'app/controllers/triumph/achievements_controller.rb', line 38 def edit @achievement = Achievement.find(params[:id]) end |
#index ⇒ Object
GET /achievements GET /achievements.xml
5 6 7 8 9 10 11 12 |
# File 'app/controllers/triumph/achievements_controller.rb', line 5 def index @achievements = Achievement.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @achievements } end end |
#new ⇒ Object
GET /achievements/new GET /achievements/new.xml
28 29 30 31 32 33 34 35 |
# File 'app/controllers/triumph/achievements_controller.rb', line 28 def new @achievement = Achievement.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @achievement } end end |
#show ⇒ Object
GET /achievements/1 GET /achievements/1.xml
16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/triumph/achievements_controller.rb', line 16 def show @achievement = Achievement.find(params[:id]) @conditions = @achievement.achievement_conditions respond_to do |format| format.html # show.html.erb format.xml { render :xml => @achievement } end end |
#update ⇒ Object
PUT /achievements/1 PUT /achievements/1.xml
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/triumph/achievements_controller.rb', line 63 def update @achievement = Achievement.find(params[:id]) @achievement.observe_class.downcase! respond_to do |format| if @achievement.update_attributes(params[:triumph_achievement]) format.html { redirect_to(@achievement, :notice => 'Achievement was successfully updated.') } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @achievement.errors, :status => :unprocessable_entity } end end end |