You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by as...@apache.org on 2008/11/19 00:33:11 UTC

svn commit: r718785 - in /ode/sandbox/singleshot/config: environment.rb environments/development.rb initializers/active_presenter.rb initializers/locale.rb

Author: assaf
Date: Tue Nov 18 15:33:11 2008
New Revision: 718785

URL: http://svn.apache.org/viewvc?rev=718785&view=rev
Log:
Another change for keeping up with Rails edge.

Added:
    ode/sandbox/singleshot/config/initializers/active_presenter.rb
Modified:
    ode/sandbox/singleshot/config/environment.rb
    ode/sandbox/singleshot/config/environments/development.rb
    ode/sandbox/singleshot/config/initializers/locale.rb

Modified: ode/sandbox/singleshot/config/environment.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/environment.rb?rev=718785&r1=718784&r2=718785&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/environment.rb (original)
+++ ode/sandbox/singleshot/config/environment.rb Tue Nov 18 15:33:11 2008
@@ -18,7 +18,7 @@
 
 ENV['RAILS_ENV'] ||= 'production'
 # TODO:  Uncomment this when we finally upgrade to Rails 2.2.
-# RAILS_GEM_VERSION = '2.2.0' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.2.0' unless defined? RAILS_GEM_VERSION
 # Bootstrap the Rails environment, frameworks, and default configuration
 require File.join(File.dirname(__FILE__), 'boot')
 

Modified: ode/sandbox/singleshot/config/environments/development.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/environments/development.rb?rev=718785&r1=718784&r2=718785&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/environments/development.rb (original)
+++ ode/sandbox/singleshot/config/environments/development.rb Tue Nov 18 15:33:11 2008
@@ -23,7 +23,7 @@
 config.action_controller.allow_concurrency = true
 
 config.gem 'annotate-models', :lib=>'annotate_models'
-#config.gem 'rspec', :lib=>'spec',          :version=>'~> 1.1.4'
+config.gem 'rspec', :lib=>'spec',          :version=>'~> 1.1.4'
 config.gem 'faker',                         :version=>'~>0.3'  # Faker: Used to populate development database with fake data.
 config.gem 'sqlite3-ruby', :lib=>'sqlite3', :version=>'~>1.2'  # SQLite3: Development and test databases use SQLite3 by default.
 config.gem 'thin',                          :version=>'~>0.8'  # Thin: Not essential, but development scripts (e.g. rake run) are hard wired to use Thin.
\ No newline at end of file

Added: ode/sandbox/singleshot/config/initializers/active_presenter.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/initializers/active_presenter.rb?rev=718785&view=auto
==============================================================================
--- ode/sandbox/singleshot/config/initializers/active_presenter.rb (added)
+++ ode/sandbox/singleshot/config/initializers/active_presenter.rb Tue Nov 18 15:33:11 2008
@@ -0,0 +1,39 @@
+class ActiveRecord::Base
+  include ActionController::UrlWriter
+  
+  class << self
+    def default_url_options #:nodoc
+      Thread.current[:request_options] ||= {}
+    end
+  end
+  
+  # Returns GUID for current object.  A GUID is s URN that identifies the host, object
+  # type and object identifier, for example, guid for a Task model could be urn:example.com/tasks/1.
+  def guid
+    @guid ||= "urn:#{self.class.default_url_options[:host]}/#{ActionController::RecordIdentifier.singular_class_name(self)}/#{id}"
+  end
+
+  # Return URL for current object using polymorphic routes.  For example, calling
+  # href on Task model returns task_url(self), or http://example.com/tasks/1.
+  def href
+    @href ||= polymorphic_url(self)
+  end
+end
+
+
+class ActionController::Base
+  
+  around_filter :set_active_record_host
+
+private
+
+  def set_active_record_host
+    options = { :protocol=>request.protocol, :host=>request.host }
+    options[:port] = request.port unless request.port == 80
+    Thread.current[:request_options] = options
+    yield
+  ensure
+    Thread.current[:request_options] = nil
+  end
+
+end
\ No newline at end of file

Modified: ode/sandbox/singleshot/config/initializers/locale.rb
URL: http://svn.apache.org/viewvc/ode/sandbox/singleshot/config/initializers/locale.rb?rev=718785&r1=718784&r2=718785&view=diff
==============================================================================
--- ode/sandbox/singleshot/config/initializers/locale.rb (original)
+++ ode/sandbox/singleshot/config/initializers/locale.rb Tue Nov 18 15:33:11 2008
@@ -15,6 +15,4 @@
 
 
 # Load all the locale files for Singleshot (app and libraries).
-Dir["#{Rails.root}/lib/locale/*.yml"].each do |path|
-  I18n.load_translations path
-end
\ No newline at end of file
+I18n.load_path.push *Dir["#{Rails.root}/lib/locale/*.yml"]
\ No newline at end of file