Skip to content
Browse files

Setup boiler plate associative array for the text and filenames

  • Loading branch information...
1 parent 3fb94dc commit 3299fb71269ca2079b38f89c29624a328d315d5b @edmore committed
Showing with 6 additions and 2 deletions.
  1. +5 −1 peekaboo.rb
  2. +1 −1 views/start.haml
View
6 peekaboo.rb
@@ -24,6 +24,7 @@
question_id = redis.incr "question:id"
redis.rpush("questions", question_id)
redis.set("question:#{question_id}:text", params[:question])
+ redis.set("question:#{question_id}:filename", (params[:question]).reverse)
status = :success
end
redirect "/push?status=#{status}"
@@ -32,11 +33,14 @@
get "/start" do
length = redis.llen("questions")
all_text = []
+ all_filenames = []
(length).times do
question_id = redis.lpop("questions")
all_text << redis.get("question:#{question_id}:text")
+ all_filenames << redis.get("question:#{question_id}:filename")
end
- haml :start, :locals => {:all_text => all_text}
+ player_files = all_text.zip(all_filenames)
+ haml :start, :locals => {:player_files => player_files}
end
get "/clear" do
View
2 views/start.haml
@@ -1,2 +1,2 @@
:javascript
- var all_text = #{all_text};
+ var player_files = #{player_files};

0 comments on commit 3299fb7

Please sign in to comment.
Something went wrong with that request. Please try again.