I'm using the login_system gem which works fine on my dev. environment
(RadRails / webbrick). Also my hosting company (A2) installed the same
GEM. But when I try to login on the production server, I get:
NoMethodError in AccountController#login
undefined method `redirect_back_or_default' for
#<AccountController:0x2a96ffa088>
I added require_gem 'login_generator' to the environment.rb, but no
dice. How would I determine what other dependencies are required?
When the gem was installed in my environment it created the file
login_system.rb in my lib directory. This defines a module LoginSystem
which includes the method redirect_back_or_default.
Does this somehow need to be included? Still don't understand why it
complains in production mode but is fine in dev. mode.
No, require_gem is deprecated and should not be used unless you need to require a specific version of a gem. It will be removed in subsequent rubygems releases. Don't use it because it is misleading and doesn't really do what it seems like it should do. TO require an installed gem you only need to do this:
require 'rubygems'
require 'gemname'
And rails already requires rubygems unless you have rails frozen in vendor.
I just wanted to give everybody an update. I was completely frustrated
with this gem. The hosting company (A2) gave me their response:
"Unfortunately, it is beyond the scope of our support to debug
applications/code for customers"
Anyway, I cancelled my account with them and moved over to DreamHost.
Followed their very through Wiki instructions and it now works
perfectly.
i suppose on top of this you could create a file in your
/config/initializers/ directory to load all the gems your app needs;
making things a little more neat.
haven't tried myself but should be possible rather than sticking it into
your environment.rb file all the time