Rails route error? uninitialized constant ActiveResource::Base - ruby-on-rails

I'm following the Getting Started with Rails guide but ran into an issue opening http://localhost:3000
Shell output:
[2010-03-23 19:19:14] ERROR NameError: uninitialized constant ActiveResource::Base
Error in the browser:
Internal Server Error
uninitialized constant ActiveResource::Base
WEBrick/1.3.1 (Ruby/1.8.7/2009-06-12) at localhost:3000
I followed the directions exactly as they were specified in the guide:
Ran rails generate controller home index
I removed index.html
Added root :to => "home#index" to config/routes.rb
I checked app/views/home/index.html.erb and it is indeed there.
I then used rails server to launch the server. At first attempt the browser loads a blank page, but afterwards starts showing the browser error above.
Why is it that Rails can't locate the index.html.erb file? Or is the error something different?
-
Running Rails 3.0beta with Ruby 1.8.7

uninitialized
constant ActiveResource::Base
It looks like there's a problem with your Ruby/Rails setup.
Do you have more than one version of Ruby on your system? It could be that the version of Ruby you're using to run your app is looking for the Rails gems (ActiveResource::Base) in the wrong repository.

If you're using the Getting Started guide I recommend that you don't use Rails 3.0 beta, as, well, it's a beta release. It's best to use the stable-of-the-moment 2.3.5.

I have this error as well. I am running Ruby 1.8.7 p249 under RVM - Rails 3 beta3 on Ubuntu (Lucid Lynx). The strange thing is I have the exact same setup (RVM, Ruby version & gems) on my Mac and it works fine.
UPDATE: I tried again using RVM to switch to Ruby-1.9.2-HEAD and everything is working as expected. Still doesn't solve problem but it get Rails 3 working at least.

Related

Rails 6 - Phusion error for uninitialized constant URI::Generic

I'm using rails 6.0.3.4, ruby 2.5.0 with nginx/1.18.0 (Ubuntu). Everything was fine until I did a new deploy (using capistrano) and suddenly I'm getting Could not spawn process for application /home/deploy/appname/current: The application encountered the following error: uninitialized constant URI::Generic (NameError).
I have required these in application.rb (also tested requiring in the model) with no luck:
require 'uri'
require "uri/generic"
At this point, I'm not sure what could be wrong.
Thanks in advance if anyone has any suggestions.
It seemed it was a bug between Rails and Ruby, so I upgraded my Rails to the current stable version as well as upgraded my ruby version.

Rails server keep failing. NoMethodError `new_with_config'

I installed rails recently and I have been having quite a bit of trouble just trying to install everything, but it is finally done and now when I try to launch a rails server I always get an error and the server ends up stoping at that exact moment.
Here is what it says:
NoMethodError `new_with_config' for
ActionDispatch::Routing::RouteSet:Class.
I am using Rails version 5.0.0.1

Routing error after upgrading to Rails 3.2.14

I recently upgraded my app to the asset pipeline while on Rails 3.2.11, and in the process decided to use the Heroku Rails Deflate gem to help with gzip compression and cache control headers on the Cedar stack. There were dependency issues so I had to upgrade to Rails 3.2.14.
After the upgrade, I could not run my tests or even start my Rails server. There error I get is:
missing :action (ArgumentError)
/Users/mackshkatz/.rvm/gems/ruby-1.9.2-p290#xxxxxx/gems/actionpack-3.2.14/lib/action_dispatch/routing/mapper.rb:178:in `default_controller_and_action'
The issue is fixed when I comment out line 3 in my routes.rb file:
Blogmutt::Application.routes.draw do
root :to => 'pages#home'
put 'reports/save_customer_tracking/'
I have no idea why this is suddenly breaking. I can start up the server with it commented out, but of course the form in my app that uses the named route generated from that line is now broken.
Why is this line suddenly broken?

Rails authenticate_or_request_with_http_basic not working on SSL + Nginx

I've get an action in my Rails 3 app that I'm pw-protecting with authenticate_or_request_with_http_basic. Working fine on my development machine but it's not prompting for the http_basic user/password on the production server.
The entire production app runs over https/SSL on nginx.
Where do I look to resolve this? Does http basic auth not work over SSL? Or is there an nginx setting I need to look at?
TIA
Not sure if this related to Rails 3.
I just recently had problems running Mongrel 1.1.5 and Rails 2.3.8
Apparently, there is a bug in this set up where our production machine does not prompt for the user name and password (but works locally, because we are using web-brick).
In the mongrel.log we keep getting this error:
Error calling Dispatcher.dispatch #split' called for nil
:NilClass>
/usr/local/rvm/gems/ruby-1.8.7-p174/gems/actionpack-2.3.8/lib/action_controller/cgi_process.rb:52:indispatch_cgi'
/usr/local/rvm/gems/ruby-1.8.7-p174/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'
...
Found the monkey patch needed to fix this Mongrel 1.1.5 and Rails 2.3.8 and it worked for me.
The german site that lead to the solution: http://railssprech.de/ with 2 links for 2.3.8 and 2.3.9.
Here is the 2.3.8 version: http://www.pcoder.net/error-calling-dispatcher-dispatch/#axzz1RknBQso2
The patch explains why this error was occurring. Check the Rails 3 CGIHandler.dispatch_cgi method and see if it the same bug. You may need to extract the Rails 3 out and monkey patch it.
Hope this helps.
BTW: Mongrel 1.1.5 and Rails 2.3.5 works!

Rails error 500 on local mac

Ok, I'm a noob with rails... so I just set up rails with RVM and created a new project, and when I try to visit a newly created view I'm getting an error 500.
Heres my setup:
OSX 10.6.5
Installed MySQL 64bit
RVM installed ruby 1.8.7 and rails 2.3.8 (no other rails or ruby except for the system ruby) rvm install 1.8.7, rvm use --create 1.8.7#rails2, gem install rails -v=2.3.8
Passenger with Apache gem install passenger, rvmsudo passenger-install-apache2-module
Passenger preference pane
Turned on websharing
I then proceeded to setup a rails project in my development folder called testapp, added it in the passenger preference pane, and then ran script/generate controller Say, defined an action hello, and then created a view in the app/view/say folder called hello.
Now I'm getting a 500 error when visiting myapp.local/say/hello, what am i doing wrong?
UPDATE:
I checked the logs and also tried running using WEBrick instead of passenger and apache. I got thrown back the same errors. I don't think I should post the entire log, should I? But the first error is
no such file to load -- sqlite3
I have not yet setup a db, I was going to use mysql, but I didn't want to install it since I'm not using models yet. Is it a requirement?
UPDATE 2:
So I installed the mysql gem with gem install mysql -- --include=/usr/local/lib (not sure if this is right). I then created a rails app with rails -d mysql myapp. And set the password in the database.yml. I'm getting a new error now:
Unknown database 'myapp_development'
So I have to create a database. Why am I being forced to create a db at all?
Yeah, you need to install sqlite even if you're not using models yet - Rails checks to make sure whatever is specified in database.yml is actually there to use.
Don't access it through passenger, launch it using ruby script/server and check out the error it throws there. Generally those errors are way more descriptive than Passenger because Passenger is probably running your application using the production environment.
Hey Ryan, do you need to Ruby 1.8.7? Why don't you install the latest 1.9.2 and Rails 3? I have the same environment and so far no problems. Here is a link for installing everything you need. Let me know if it helped! http://amerine.net/2010/02/24/rvm-rails3-ruby-1-9-2-setup.html
Salud!

Resources