Skip to content
This repository has been archived by the owner on Nov 26, 2020. It is now read-only.

Commit

Permalink
Destroy a state when leaving a game.
Browse files Browse the repository at this point in the history
Fixed #111
  • Loading branch information
Christopher Peplin committed Nov 4, 2010
1 parent ec8a27f commit a02fe0f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/controllers/states_controller.rb
@@ -1,7 +1,7 @@
class StatesController < ApplicationController
before_filter :login_required
before_filter :game_required
before_filter :find_state, :only => [:show, :edit, :update]
before_filter :find_state, :only => [:show, :edit, :update, :destroy]

respond_to :json, :except => [:new, :edit]
respond_to :html
Expand All @@ -22,6 +22,12 @@ def create
respond_with @state
end

def destroy
game = @state.game
@state.destroy
redirect_to game
end

def show
respond_with @state
end
Expand Down
1 change: 1 addition & 0 deletions app/views/games/_game.html.haml
Expand Up @@ -8,6 +8,7 @@
%p
You are playing in this game.
%a{:href => games_url} Leave this game
= button_to "Leave this game", {:id => current_state.id}, :method => :delete, :confirm => "Are you sure?"

%h2 States

Expand Down
3 changes: 2 additions & 1 deletion config/routes.rb
Expand Up @@ -7,7 +7,8 @@
resources :cities, :only => [:index, :show]
end

resources :states, :only => [:index, :show, :update, :create, :edit] do
resources :states,
:only => [:index, :show, :update, :create, :edit, :destroy] do
resources :cities, :only => [:index, :show]
resources "interstate-lines", :controller => :interstate_lines,
:as => :interstate_lines,
Expand Down

0 comments on commit a02fe0f

Please sign in to comment.