forked from deanrad/chess_on_rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to drop in other sets of pieces.
Select box on match to pick which of the available sets you are using. File and Directory queries to determine available sets. Current set name is stored in session[:set] and matches the name of the directory holding the set
- Loading branch information
Sean Corbett
committed
Jan 17, 2009
1 parent
8f02bae
commit 5ab4b98
Showing
6 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Manages the addition and updating of players and their information | ||
class SetsController < ApplicationController | ||
|
||
def change | ||
session[:set] = params[:set] | ||
redirect_to :back | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module SetsHelper | ||
|
||
def available_sets | ||
Dir.glob("#{Rails.public_path}/images/sets/**"). | ||
select{|f| File.directory?( f) }. | ||
map{|d| d.split("/").last} | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h3>Available Chess Sets</h3> | ||
<%- set = session[:set] || "default" %> | ||
<%- form_for :set, :url => {:controller => "sets", :action => "change"} do |f| %> | ||
<%= select_tag "set", options_for_select(available_sets, set) %> | ||
<%= submit_tag 'Change' %> | ||
<%- end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters