Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: dslh/bilingue
base: 76c27adecf
...
head fork: dslh/bilingue
compare: 178d807848
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 16, 2012
@dslh Tidying up a warning on heroku's servers. 7b63cd8
@dslh Working around a bug in rocket_tag.
rocket_tag's `tagged_with` method fails when running on top of PostgreSQL.
See bradphelan/rocket_tag#6
178d807
View
21 app/controllers/quizzes_controller.rb
@@ -1,11 +1,24 @@
class QuizzesController < ApplicationController
- # GET /quizzes/tag+tag2/20
+ # GET /quizzes/language/1/tag+tag2/20
def show
@tags = params[:tags].split('+')
@language = Language.find(params[:language])
- @phrases = @language.phrases.tagged_with(@tags)
- length = [params[:length].to_i || 10, @phrases.length].min
- @phrases = @phrases.shuffle[0...length]
+# The below code is preferred but at present
+# there is an issue with rocket_tag + postgresql.
+# @phrases = @language.phrases.tagged_with(@tags)
+# length = [params[:length].to_i || 10, @phrases.length].min
+# @phrases = @phrases.shuffle[0...length]
+ @phrases = Phrase.find_by_sql("
+ SELECT * FROM phrases WHERE #{@tags.length} = (
+ SELECT count(*) FROM taggings JOIN tags
+ ON tags.id = taggings.tag_id
+ WHERE tags.name IN (
+ #{@tags.collect { |t| "'#{t}'" }.join(',')}
+ ) AND taggings.taggable_id = phrases.id
+ AND taggings.taggable_type = 'Phrase'
+ ) AND language_id=#{@language.id}
+ ORDER BY random() LIMIT #{params[:length] || 10}
+ ")
respond_to do |format|
format.html { render 'quiz' }
View
3  config/environments/production.rb
@@ -1,4 +1,7 @@
LearnFrench::Application.configure do
+ # Tidying up a noisy deprecation warning on heroku's servers
+ ::ActiveSupport::Deprecation.silenced = true
+
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests

No commit comments for this range

Something went wrong with that request. Please try again.