Permalink
Browse files

Working on Rails 3.1.1, removed warnings, added will_paginate support…

… again.
  • Loading branch information...
1 parent 06956fd commit 70f755e151b5587a89577bb751cc2d222aae949d @miloops committed Nov 6, 2011
View
@@ -1,9 +1,8 @@
source "http://rubygems.org"
-#gem "rails", "3.1.0.beta1"
-gem 'rails', :git => 'git://github.com/rails/rails.git'
+gem "rails", "3.1.1"
-gem 'kaminari', :git => "https://github.com/amatsuda/kaminari.git"
+gem 'will_paginate'
gem "ya2yaml"
gem "capybara", :git => "https://github.com/jnicklas/capybara.git"
View
@@ -134,7 +134,8 @@ def phrases_without_translation(page = nil, options = {})
existing_ids = self.translations.all(:select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq
phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?)', existing_ids]) if existing_ids.present?
- result = phrases.page(page).per(Tolk::Phrase.per_page)
+ result = phrases.paginate({:page => page, :per_page => Phrase.per_page}.merge(options))
+ ActiveRecord::Associations::Preloader.new result, :translations
result
end
@@ -150,7 +151,7 @@ def search_phrases(query, scope, page = nil, options = {})
phrases = Tolk::Phrase.scoped(:order => 'tolk_phrases.key ASC')
phrases = phrases.scoped(:conditions => ['tolk_phrases.id IN(?)', translations.map(&:phrase_id).uniq])
- phrases.page(page)
+ phrases.paginate({:page => page}.merge(options))
end
def search_phrases_without_translation(query, page = nil, options = {})
@@ -162,7 +163,8 @@ def search_phrases_without_translation(query, page = nil, options = {})
existing_ids = self.translations.all(:select => 'tolk_translations.phrase_id').map(&:phrase_id).uniq
phrases = phrases.scoped(:conditions => ['tolk_phrases.id NOT IN (?) AND tolk_phrases.id IN(?)', existing_ids, found_translations_ids]) if existing_ids.present?
- result = phrases.page(page)
+ result = phrases.paginate({:page => page}.merge(options))
+ ActiveRecord::Associations::Preloader.new result, :translations
result
end
@@ -198,7 +200,7 @@ def get(key)
def translations_with_html
translations = self.translations.all(:conditions => "tolk_translations.text LIKE '%>%' AND
tolk_translations.text LIKE '%<%' AND tolk_phrases.key NOT LIKE '%_html'", :joins => :phrase)
- Translation.send :preload_associations, translations, :phrase
+ ActiveRecord::Associations::Preloader.new translations, :phrase
translations
end
@@ -217,14 +219,16 @@ def remove_invalid_translations_from_target
end
def find_phrases_with_translations(page, conditions = {})
- result = Tolk::Phrase.page(page).find(:all,
+ result = Tolk::Phrase.paginate(:page => page,
:conditions => { :'tolk_translations.locale_id' => self.id }.merge(conditions),
:joins => :translations, :order => 'tolk_phrases.key ASC')
result.each do |phrase|
phrase.translation = phrase.translations.for(self)
end
+ ActiveRecord::Associations::Preloader.new result, :translations
+
result
end
@@ -53,7 +53,7 @@
<p><%= locale_form.submit "Save changes" %></p>
</div>
<div class="paginate">
- <%= paginate @phrases %>
+ <%= will_paginate @phrases %>
</div>
<% end %>
<% else %>
@@ -49,7 +49,7 @@
</div>
<% end %>
<div class="paginate">
- <%= paginate @phrases %>
+ <%= will_paginate @phrases %>
</div>
<% else %>
<p style="text-align: left">There aren't any missing or updated phrases that need translation.</p>
@@ -47,7 +47,7 @@
</div>
<% end %>
<div class="paginate">
- <%= paginate @phrases %>
+ <%= will_paginate @phrases %>
</div>
<% else %>
<p style="text-align: left">No search results.</p>
View
@@ -1,4 +1,4 @@
-require 'kaminari'
+require 'will_paginate'
require 'ya2yaml'
require 'tolk/engine'
require 'tolk/sync'
@@ -9,7 +9,7 @@ def test_adding_locale
def test_adding_missing_translations_and_updating_translations
Tolk::Locale::MAPPING['xx'] = "Pirate"
-
+
locale = add_locale("Pirate")
assert locale.translations.empty?
@@ -41,7 +41,7 @@ def add_locale(name)
select name, :from => "select_tolk_locale_name"
click_button 'Add'
- Tolk::Locale.find_by_name!(Tolk::Locale::MAPPING.index(name))
+ Tolk::Locale.find_by_name!(Tolk::Locale::MAPPING.key(name))
end
def setup_locales
@@ -1,6 +1,6 @@
# Define a bare test case to use with Capybara
class ActiveSupport::IntegrationCase < ActiveSupport::TestCase
- include Capybara
+ include Capybara::DSL
include Rails.application.routes.url_helpers
include Rails.application.routes.mounted_helpers
end

0 comments on commit 70f755e

Please sign in to comment.