google-code-export / rubycas-client

Automatically exported from code.google.com/p/rubycas-client
1 stars 1 forks source link

Error: "uninitialized constant CASClient" when installed as Rails plugin #15

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try installing CAS client at <AppFolder> "ruby script/plugin install 
http://rubycas-client.googlecode.com/svn/trunk/rubycas-client"
2.
3.

What is the expected output? What do you see instead?
I see, <appFolder>\vendor\plugins is not a working copy and seems to be 
updating other files.

What version of the product are you using? On what operating system?
Ruby: 186, Rails : 2.0.2, Windows XP - Professional

Please provide any additional information below.

 Added CASClient::Frameworks::Rails::Filter.configure(
    :cas_base_url => "https://cas.example.foo/"
  ) in config/environment.rb
and before_filter CASClient::Frameworks::Rails::Filter to 
app/controllers/application.rb

Now run the server as ruby script/server, server is throwing erros saying 
uninitialized CAS Client errors

============================ EXCEPTIONS ===========

dependencies.rb:266:in `load_missing_constant': uninitialized constant 
CASClient
 (NameError)
        from c:/noscan/Ruby186/lib/ruby/gems/1.8/gems/activesupport-
2.0.2/lib/ac
tive_support/dependencies.rb:453:in `const_missing'
        from c:/noscan/Ruby186/lib/ruby/gems/1.8/gems/activesupport-
2.0.2/lib/ac
tive_support/dependencies.rb:465:in `const_missing'
        from C:/noscan/tempRubyPjt/testPjt/config/environment.rb:8
        from 
c:/noscan/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
:27:in `gem_original_require'
        from 
c:/noscan/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
:27:in `require'
        from c:/noscan/Ruby186/lib/ruby/gems/1.8/gems/activesupport-
2.0.2/lib/ac
tive_support/dependencies.rb:496:in `require'
        from c:/noscan/Ruby186/lib/ruby/gems/1.8/gems/activesupport-
2.0.2/lib/ac
tive_support/dependencies.rb:342:in `new_constants_in'
        from c:/noscan/Ruby186/lib/ruby/gems/1.8/gems/activesupport-
2.0.2/lib/ac
tive_support/dependencies.rb:496:in `require'
         ... 21 levels...
        from c:/noscan/Ruby186/lib/ruby/gems/1.8/gems/rails-
2.0.2/lib/commands/s
erver.rb:39
        from 
c:/noscan/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
:27:in `gem_original_require'
        from 
c:/noscan/Ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
:27:in `require'
        from script/server:3
=============================================================

Original issue reported on code.google.com by sgod...@gmail.com on 20 Feb 2008 at 11:34

GoogleCodeExporter commented 9 years ago
I'm having a hard time reproducing your problem. I tried it on a fresh XP 
machine and
it worked fine. Here's what I did:

1. Installed the latest version of Rails: `gem install -y rails`
2. Created a fresh Rails application: `rails my_test`
3. Configured the database for the my_test app.
4. Generated a test controller: `ruby script\generate controller test`
5. Installed the RubyCAS-Client plugin: `ruby script/plugin install
http://rubycas-client.googlecode.com/svn/trunk/rubycas-client`
6. Configured the CAS client in config\environment.rb.
7. Added the filter to the Test controller: "before_filter
CASClient::Frameworks::Rails::Filter"

Now when I try to visit http://localhost:3000/test it works fine, redirecting 
me to
the CAS login page.

Can you repeat the steps above and let me know if you're still having problems? 

Original comment by matt.zuk...@gmail.com on 21 Feb 2008 at 8:15

GoogleCodeExporter commented 9 years ago
Reading over your bug report, it sounds like something may be wrong with the 
way the
plugin is getting installed. Can you be a bit more specific about what hapens 
when
you run:

  ruby script/plugin install 
    http://rubycas-client.googlecode.com/svn/trunk/rubycas-client

Also you mention that it is not a "working copy". If you're looking to check 
out a
subversion repo then you need to use the -x flag with your plugin install:

  ruby script/plugin install -x 
    http://rubycas-client.googlecode.com/svn/trunk/rubycas-client

If all else fails, you can try installing the client as a rubygem:

  gem install rubycas-client

If you install as a gem, make sure you add "require 'rubycas-client'" to your
environment.rb file.

Original comment by matt.zuk...@gmail.com on 21 Feb 2008 at 8:32

GoogleCodeExporter commented 9 years ago
Matt,
Thank you very much for quick response.
I just followed your steps 1 to 7 and now CAS plug in installed successfully. I 
don't see "not a working copy" error any more.
but still getting "`load_missing_constant': uninitialized constant CASClient
 (NameError)".

Here I am my configurations:
config/environment.rb
===================
# Be sure to restart your server when you modify this file

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those specified here.
  # Application configuration should go into files in config/initializers
  # -- all .rb files in that directory are automatically loaded.
  # See Rails::Configuration for more options.

CASClient::Frameworks::Rails::Filter.configure(
    :cas_base_url => "https://cas.example.foo/"
  )

  # Skip frameworks you're not going to use (only works if using vendor/rails).
  # To use Rails without a database, you must remove the Active Record framework
  # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

  # Only load the plugins named here, in the order given. By default, all plugins 
  # in vendor/plugins are loaded in alphabetical order.
  # :all can be used as a placeholder for all plugins not explicitly named
  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Force all environments to use the same logger level
  # (by default production uses :info, the others :debug)
  # config.log_level = :debug

  # Your secret key for verifying cookie session data integrity.
  # If you change this key, all old sessions will become invalid!
  # Make sure the secret is at least 30 characters and all random, 
  # no regular words or you'll be exposed to dictionary attacks.
  config.action_controller.session = {
    :session_key => '_HelloProjects_session',
    :secret      
=> 
'b96668e0b0bc1db4d515650600d0dfadf284cb111477add9ff61b79c5dae007c664f444576b16f4
06
5b2d3b7ee0fc0bae0d2723c60834b681a157ce42312f4b5'
  }

  # Use the database for sessions instead of the cookie-based default,
  # which shouldn't be used to store highly confidential information
  # (create the session table with 'rake db:sessions:create')
  # config.action_controller.session_store = :active_record_store

  # Use SQL instead of Active Record's schema dumper when creating the test database.
  # This is necessary if your schema can't be completely dumped by the schema dumper,
  # like if you have constraints or database-specific column types
  # config.active_record.schema_format = :sql

  # Activate observers that should always be running
  # config.active_record.observers = :cacher, :garbage_collector

  # Make Active Record use UTC-base instead of local time
  # config.active_record.default_timezone = :utc
end
======================================
app/test_controller.rb

class TestController < ApplicationController
before_filter CASClient::Frameworks::Rails::Filter
end

any help is greatly appreciated.

Original comment by sgod...@gmail.com on 21 Feb 2008 at 9:20

GoogleCodeExporter commented 9 years ago
Ahh! Put your CASClient configuration AFTER the Rails::Initializer stuff -- 
i.e. at
the very bottom of your environment.rb file.

The Rails Initializer is for configuring only Rails itself. You should never 
put code
in there that concerns third-party libraries like RubyCAS.

I think once you do this you should find that it works fine.

Original comment by matt.zuk...@gmail.com on 27 Feb 2008 at 8:07

GoogleCodeExporter commented 9 years ago
Excellent. I have it working now. Thank you very much for your support. :)

Original comment by sgod...@gmail.com on 4 Mar 2008 at 6:52