Topic: Please help, complete newbie question

I am first learning ruby on rails, and am running into a lot of difficulties.  I am attempting to run rails in the latest version of Ubuntu (9.04, i believe it is the jaunty version).  I believe I finally have it installed following the method listed on this site (http://www.hackido.com/2009/04/install- … aunty.html).  This is after several other different installations, which I'm not sure if I've completely removed.  I am following along with a tutorial posted on this site (http://oreilly.com/pub/a/ruby/archive/rails.html?). 

I am now running into difficulties either setting up a local server or creating a controller.  I'm just using the default WEBrick v1.3.1 server application running in my terminal.  When I browse to "http://localhost:3000/" or "http://127.0.0.1:3000/", I get a nice website saying Welcome aboard, you're riding ruby on rails.  However, I have created a very general controller using generate controller MyTest.  I have edited the ruby file my_test_controller.rb and added an index with render_text "Hello World" just as the tutorial says to do.  When I attempt to browse to http://localhost:3000/My_Test or http://127.0.0.1:3000/My_Test, or even http://127.0.0.1:3000/My_Tes or http://127.0.0.1:3000/garbage I get a message saying "We're sorry, but something went wrong, we've been notified about the issue and will take a look at it shortly."

What my terminal says:

/!\ FAILSAFE /!\  Fri Sep 25 07:36:06 -0400 2009
  Status: 500 Internal Server Error
  no such file to load -- sqlite3
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/dependencies.rb:156:in `require'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/requires.rb:7:in `require_library_or_gem'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.4/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/sqlite3_adapter.rb:10:in `sqlite3_connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout'
    /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:9:in `cache'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_cache.rb:28:in `call'
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/head.rb:9:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/methodoverride.rb:24:in `call'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params_parser.rb:15:in `call'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/session/cookie_store.rb:93:in `call'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsafe.rb:26:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `synchronize'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/lock.rb:11:in `call'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:114:in `call'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reloader.rb:34:in `run'
    /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispatcher.rb:108:in `call'
    /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:46:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `each'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/urlmap.rb:40:in `call'
    /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:46:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
    /usr/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/webrick.rb:13:in `run'
    /usr/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3


my_test_controller.rb
class MyTestController < ApplicationController
    def index
        render_text "Hello World"
    end
end

Re: Please help, complete newbie question

Hi

If you take a look at the error message it says at the top

no such file to load -- sqlite3

This means that you do not have sqlite installed. This is the default datebase in rails. You can use others like mysql or postgresql. But, sqlite is greate for development and production on small sites.

Run these in the consol

sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby

and I belive you are set to go

Re: Please help, complete newbie question

hey, thanks a lot for the help that worked perfectly.

Re: Please help, complete newbie question

glad to help!

Re: Please help, complete newbie question

Thank you anneflyr this response helped me too.

anneflyr wrote:

Hi

If you take a look at the error message it says at the top

no such file to load -- sqlite3

This means that you do not have sqlite installed. This is the default datebase in rails. You can use others like mysql or postgresql. But, sqlite is greate for development and production on small sites.

Run these in the consol

sudo apt-get install libsqlite3-dev
sudo gem install sqlite3-ruby

and I belive you are set to go

Re: Please help, complete newbie question

Hello ,

While I was trying to generate model using the following command its giving me an error.
COMMAND : ruby script/generate model Book
ERRO:
C:\Ruby\library>ruby script/generate model Book
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 29, col 0: `use
rname: prerna' (ArgumentError)
        from C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load'
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:902:i
n `database_configuration'
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:437:i
n `initialize_database'
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:141:i
n `process'
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:i
n `send'
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/initializer.rb:113:i
n `run'
        from C:/Ruby/library/config/environment.rb:9
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `ge
m_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `re
quire'
        from C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/generate.rb
:1
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `ge
m_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `re
quire'
        from script/generate:3

ANY SUGGESTIONS IN THIS REGARD ARE HIGHLY APPRICIATED .

thankyou

Re: Please help, complete newbie question

did you just try script/generate model Book.

Re: Please help, complete newbie question

You MUST browse to your application directory before doing any generating scripts like that:

cd path/to_your/rails_application

After that you can run any ruby script/generate stuffs

Re: Please help, complete newbie question

Thank you so much. I will try that

Re: Please help, complete newbie question

thnx for the help ................

Re: Please help, complete newbie question

I am getting a 500 error too. I am just trying to follow this tutorial http://www.tutorialspoint.com/ruby-on-r … views.htm. After I created a new controller using this command

:\ruby\library\> ruby script/generate controller Book

I added Some methods to book_controller.rb

class BookController < ApplicationController
   def list
      @books = Book.find(:all)
   end
   def show
      @book = Book.find(params[:id])
   end
   def new
      @book = Book.new
      @subjects = Subject.find(:all)
   end
   def create
      @book = Book.new(params[:book])
      if @book.save
            redirect_to :action => 'list'
      else
            @subjects = Subject.find(:all)
            render :action => 'new'
      end
   end
   def edit
      @book = Book.find(params[:id])
      @subjects = Subject.find(:all)
   end
   def update
      @book = Book.find(params[:id])
      if @book.update_attributes(params[:book])
         redirect_to :action => 'show', :id => @book
      else
         @subjects = Subject.find(:all)
         render :action => 'edit'
      end
   end
   def delete
      Book.find(params[:id]).destroy
      redirect_to :action => 'list'
   end
   def show_subjects
      @subject = Subject.find(params[:id])
   end
end

And then I started the server throgh c:/path to my application/ruby script/server
And then I went to http://localhost:3000/book/list..... I am not getting the expected result which is template not found.
Instead it say "we are sorry but there is some problem"

Error in my Command prompt is  pasted below:

/!\ FAILSAFE /!\  Fri Nov 20 13:49:28 -0500 2009
  Status: 500 Internal Server Error
  Access denied for user 'prerna'@'localhost' (using password: YES)
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/mysql_adapter.rb:585:in `real_connect'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/mysql_adapter.rb:585:in `connect'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/mysql_adapter.rb:199:in `initialize'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/mysql_adapter.rb:71:in `new'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/mysql_adapter.rb:71:in `mysql_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:223:in `send'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:223:in `new_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:188:in `checkout'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:184:in `loop'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:184:in `checkout'
    C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:183:in `checkout'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:98:in `connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_specification.rb:115:in `connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_ca
che.rb:9:in `cache'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/query_ca
che.rb:28:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/active_record/connecti
on_adapters/abstract/connection_pool.rb:361:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/head.rb:9:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/methodoverride.rb:24:in `
call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/params
_parser.rb:15:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/sessio
n/cookie_store.rb:93:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/failsa
fe.rb:26:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `synchroniz
e'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/lock.rb:11:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispat
cher.rb:114:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/reload
er.rb:34:in `run'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/dispat
cher.rb:108:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/static.rb:31:in `c
all'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:46:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `each'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/urlmap.rb:40:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/rails/rack/log_tailer.rb:17:i
n `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/content_length.rb:13:in `
call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:50:in
`service'
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
    C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
    C:/Ruby/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/handler/webrick.rb:14:in
`run'
    C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/commands/server.rb:111
    C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_origina
l_require'
    C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3


ANY SUGGESTIONS ARE APRECIATED ....Thanks....

Prerna