Skip to content

Commit

Permalink
changed RAILS_ROOT to Rails.root
Browse files Browse the repository at this point in the history
  • Loading branch information
amkirwan committed Feb 14, 2011
1 parent 36e7cfd commit 927c623
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
8 changes: 5 additions & 3 deletions README.rdoc
Expand Up @@ -36,6 +36,8 @@ API documentation (i.e. the RDocs) are available at http://rubycas-client.rubyfo

== Installation

<b>NOTE:</b> For compatibility with Rails 3 have a look at https://github.com/zuk/rubycas-client-rails

You can download the latest version of RubyCAS-Client from the project's rubyforge page at
http://rubyforge.org/projects/rubycas-client.

Expand Down Expand Up @@ -105,7 +107,7 @@ Here is a more complicated configuration showing most of the configuration optio
(this does not show proxy options, which are covered in the next section):

# enable detailed CAS logging
cas_logger = CASClient::Logger.new(RAILS_ROOT+'/log/cas.log')
cas_logger = CASClient::Logger.new(Rails.root+'/log/cas.log')
cas_logger.level = Logger::DEBUG

CASClient::Frameworks::Rails::Filter.configure(
Expand Down Expand Up @@ -146,7 +148,7 @@ notify the client application that the CAS session is closed. The client will au
requsts from the CAS server, but in order for this to work you must configure your Rails application as follows:

1. The Rails session store must be set to ActiveRecord: <tt>config.action_controller.session_store = :active_record_store</tt>
2. The server must be able to read and write to RAILS_ROOT/tmp/sessions. If you are in a clustered environment,
2. The server must be able to read and write to Rails.root/tmp/sessions. If you are in a clustered environment,
the contents of this directory must be shared between all server instances.
3. Cross-site request forgery protection must be disabled. In your <tt>application.rb</tt>: <tt>self.allow_forgery_protection = false</tt>.
(Or rather you may want to disable forgery protection only for actions that are behind the CAS filter.)
Expand Down Expand Up @@ -227,7 +229,7 @@ all you need to do is this:
In your <tt>config/environment.rb</tt>:

# enable detailed CAS logging for easier troubleshooting
cas_logger = CASClient::Logger.new(RAILS_ROOT+'/log/cas.log')
cas_logger = CASClient::Logger.new(Rails.root+'/log/cas.log')
cas_logger.level = Logger::DEBUG

CASClient::Frameworks::Rails::Filter.configure(
Expand Down
10 changes: 5 additions & 5 deletions examples/rails/config/boot.rb
@@ -1,7 +1,7 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb

RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
Rails.root = "#{File.dirname(__FILE__)}/.." unless defined?(Rails.root)

module Rails
class << self
Expand All @@ -21,15 +21,15 @@ def pick_boot
end

def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
File.exist?("#{Rails.root}/vendor/rails")
end

def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end

def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
"#{Rails.root}/config/preinitializer.rb"
end
end

Expand All @@ -42,7 +42,7 @@ def run

class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
require "#{Rails.root}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
end
end
Expand Down Expand Up @@ -99,7 +99,7 @@ def parse_gem_version(text)

private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
File.read("#{Rails.root}/config/environment.rb")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion examples/rails/config/environment.rb
Expand Up @@ -24,7 +24,7 @@

# More complicated configuration

#cas_logger = CASClient::Logger.new(RAILS_ROOT+'/log/cas.log')
#cas_logger = CASClient::Logger.new(Rails.root+'/log/cas.log')
#cas_logger.level = Logger::DEBUG
#
#CASClient::Frameworks::Rails::Filter.configure(
Expand Down
Expand Up @@ -71,6 +71,6 @@ def render_error(msg)
end

def open_pstore
PStore.new("#{RAILS_ROOT}/tmp/cas_pgt.pstore")
PStore.new("#{Rails.root}/tmp/cas_pgt.pstore")
end
end
4 changes: 2 additions & 2 deletions lib/casclient/frameworks/rails/filter.rb
Expand Up @@ -140,7 +140,7 @@ def filter(controller)

def configure(config)
@@config = config
@@config[:logger] = Rails.logger
@@config[:logger] = Rails.logger unless @@config[:logger]
@@client = CASClient::Client.new(config)
@@log = client.log
end
Expand Down Expand Up @@ -400,7 +400,7 @@ def delete_service_session_lookup(st)
# Returns the path and filename of the service session lookup file.
def filename_of_service_session_lookup(st)
st = st.ticket if st.kind_of? ServiceTicket
return "#{RAILS_ROOT}/tmp/sessions/cas_sess.#{st}"
return "#{Rails.root}/tmp/sessions/cas_sess.#{st}"
end
end
end
Expand Down

0 comments on commit 927c623

Please sign in to comment.