问题
So I'm new to rails and am actually following a video tutorial from Lynda.com in order to learn it. I didn't follow the steps to install on the video because I heard of RVM and its been great so far with getting everything setup. But I'm still early on in the video and can't get passed something really simple... so I'm hoping someone can help me out.
Heres some background:
I have RVM installed and created 1.8.7@rails2.3.8. I was able to install both ruby and rails, and everything here is fine. I even setup a global gemset for mysql and passenger.
I'm using passenger instead of WEBrick (which the tutorial uses) and I was even able to get the apache module loaded and everything is working fine when I create a rails app. I can go to simple-cms.local and I see the intro page fine.
So here is the issue. While following the video, I got to the point where I script/generate controller say
and it created the controller fine, no errors. I then proceeded to define an action "hello" in the controller, and the corresponding view "hello.rhtml" in the app/view/say folder.
Now, when I try to visit simple-cms.local, it still works, but when I try to visit simple-cms.local/say/hello.rhtml, I get an error!
Ruby on Rails application could not be started
The application has exited during startup (i.e. during the evaluation of config/environment.rb). The error message can be found below. To solve this problem, please follow any instructions in the error message.
Error message: Missing the Rails 2.3.8 gem. Please
gem install -v=2.3.8 rails
, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
So what do I do here? I mean rails 2.3.8 is installed, so why is it telling me to install it again?
UPDATE:
I ran gem environment
from within the app directory and got this
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10.4.0]
- INSTALLATION DIRECTORY: /Users/user/.rvm/gems/ruby-1.8.7-p302@rails2
- RUBY EXECUTABLE: /Users/user/.rvm/rubies/ruby-1.8.7-p302/bin/ruby
- EXECUTABLE DIRECTORY: /Users/user/.rvm/gems/ruby-1.8.7-p302@rails2/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-darwin-10
- GEM PATHS:
- /Users/user/.rvm/gems/ruby-1.8.7-p302@rails2
- /Users/user/.rvm/gems/ruby-1.8.7-p302@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
Then ran script/console
, which worked and then ran Gems.path
, which returned
["/Users/user/.rvm/gems/ruby-1.8.7-p302@rails2", "/Users/user/.rvm/gems/ruby-1.8.7-p302@global"]
Looks fine to me, what about you guys?
UPDATE 2:
Ok, so nothing has worked for me! I haven't yet tried Passenger Standalone, but I need to use apache and I read that standalone uses nginx. What I tried so far is started from scratch, rvm implode
and then installed rvm again, ruby 1.8.7, passenger, mysql, rails 2.3.8, and thats it. I still can't get passed the default page when visiting my app! I also then tried following the guides Chris Johnsen linked to in the comments to no avail.
All ideas are welcome...
回答1:
The issue was that I was installing passenger into the global gemset, which shouldn't be a problem, but it was.
I uninstalled passenger from the global gemset, and installed it into the project gemset that I'm using. This solved the missing rails gem error, and now I'm getting a 500 error when trying to visit simple-cms.local/say/hello. I'll create a new question for that and mark this one solved!
回答2:
Try Phusion Passenger Standalone. Each instance will use the currently loaded RVM and gemset.
来源:https://stackoverflow.com/questions/4136894/missing-rails-gem-error-but-its-installed