Topic: creating 1st web app - 500 error

I'm running Vista and installed version ruby186-27_rc2.

I just installed Ruby then went through the process of setting up Rails. After all that I than began to create a test app. Below are my steps.

1. Make a directory at the root level of drive C.  c:\>md rubydev

2. change to directory  c:\>cd rubydev

3. create a hellp app   c:\rubydev>rails hello
      create
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  config/initializers
      create  config/locales
      create  db
      create  doc
      create  lib
      create  lib/tasks
      create  log
      create  public/images
      create  public/javascripts
      create  public/stylesheets
      create  script/performance
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance
      create  test/unit
      create  vendor
      create  vendor/plugins
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  Rakefile
      create  README
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  config/database.yml
      create  config/routes.rb
      create  config/locales/en.yml
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/initializers/session_store.rb
      create  config/environment.rb
      create  config/boot.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  script/about
      create  script/console
      create  script/dbconsole
      create  script/destroy
      create  script/generate
      create  script/runner
      create  script/server
      create  script/plugin
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  test/test_helper.rb
      create  test/performance/browsing_test.rb
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/images/rails.png
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  doc/README_FOR_APP
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log

4. change to that directory  c:\rubydev>cd hello

5. create the controller  c:\rubydev\hello>ruby script/generate controller App
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/app
      exists  test/functional/
      create  test/unit/helpers/
      create  app/controllers/app_controller.rb
      create  test/functional/app_controller_test.rb
      create  app/helpers/app_helper.rb
      create  test/unit/helpers/app_helper_test.rb

6. made a simple html file  greeting.rhtml
<html >
<head>
<title>Ruby on Rails</title>
</head>
<body>
<h1>Yes it is working!</h1>
</body>
</html>


7. started the web server
c:\rubydev\hello>ruby script/server
=> Booting WEBrick
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2009-06-14 23:49:28] INFO  WEBrick 1.3.1
[2009-06-14 23:49:28] INFO  ruby 1.8.6 (2008-08-11) [i386-mswin32]
[2009-06-14 23:49:28] INFO  WEBrick::HTTPServer#start: pid=8060 port=3000


8. loaded the page in the browser
http://localhost:3000/app/greeting


9. Error
Error Time as the page did not load. Below is the page source.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
  <title>We're sorry, but something went wrong (500)</title>
    <style type="text/css">
        body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
        div.dialog {
            width: 25em;
            padding: 0 4em;
            margin: 4em auto 0 auto;
            border: 1px solid #ccc;
            border-right-color: #999;
            border-bottom-color: #999;
        }
        h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
    </style>
</head>
<body>
  <!-- This file lives in public/500.html -->
  <div class="dialog">
    <h1>We're sorry, but something went wrong.</h1>
    <p>We've been notified about this issue and we'll take a look at it shortly.</p>
  </div>
</body>
</html>

10. shutdown the server
ctrl-c
[2009-06-14 23:58:25] INFO  going to shutdown ...
[2009-06-14 23:58:25] INFO  WEBrick::HTTPServer#start done.
Exiting
c:\rubydev\hello>


Why did it not work?

Re: creating 1st web app - 500 error

You can get a more detailed report of the problem by looking in your log file - log/development.log

But, i'd hazard a guess that it's because you didn't create a database?

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: creating 1st web app - 500 error

Max Williams wrote:

You can get a more detailed report of the problem by looking in your log file - log/development.log

But, i'd hazard a guess that it's because you didn't create a database?

BTW, normally you would run it in development mode, and when it goes wrong you get a proper error report in the browser.

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: creating 1st web app - 500 error

Hello fwsteal,

I would have expected an error like "No route matches "/app/greeting" with {:method=>:get}", at least because you did not define a corresponding route (in config/routes.rb). Check your application logs in log/development.log to know what goes wrong.

You may want to follow this guide to start with Rails:
http://guides.rubyonrails.org/getting_started.html

Re: creating 1st web app - 500 error

Thanks for the replies! I'm 101% new to ruby on rails.

I opened the development.log file and have the following:

/!\ FAILSAFE /!\  Mon Jun 15 10:48:08 -0400 2009
  Status: 500 Internal Server Error
  no such file to load -- sqlite3
    C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/kernel/requires.rb:7:in `require_library_or_gem'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/kernel/requires.rb:5:in `require_library_or_gem'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/sqlite3_adapter.rb:10:in `sqlite3_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_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.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:123:in `retrieve_connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:115:in `connection'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:9:in `cache'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/query_cache.rb:28:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/head.rb:9:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb:24:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/params_parser.rb:15:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/rewindable_input.rb:25:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:93:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/reloader.rb:9:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/failsafe.rb:11:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/lock.rb:11:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/lock.rb:11:in `synchronize'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/lock.rb:11:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:106:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/rack/static.rb:31:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb:46:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb:40:in `each'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb:40:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/rails/rack/log_tailer.rb:17:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/content_length.rb:13:in `call'
    C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb:46: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/actionpack-2.3.2/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb:13:in `run'
    C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:111
    C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3


What is sqlite3? Any suggestions?

Re: creating 1st web app - 500 error

I've got mysql installed.

Re: creating 1st web app - 500 error

flo23,

what do i need from http://www.sqlite.org/download.html? I'm on Vista and downloaded the sqlite-3_6_15.zip which contains the sqlite3.exe file. Where does this file need to be placed to run?

Re: creating 1st web app - 500 error

Sorry I do not use Windows, but you can check those instructions:

http://blog.emson.co.uk/2008/06/install … for-rails/

Hope that helps smile

Re: creating 1st web app - 500 error

I took a look at the link below.
http://guides.rubyonrails.org/getting_started.html

1. I modified my database.yml file to have only the mysql line. How does one comment out a line in the yml file?
    3.3.2 Configuring a MySQL Database
    development: adapter: mysql encoding: utf8 database: blog_development pool: 5 username: root password: password socket: /tmp/mysql.sock

2. I then saved my file with a password of password.

3. proceeded to create the db in step 3.4
    rake db:create

4. Error - got the following:
c:\rubydev\blog>rake db:create --trace
(in c:/rubydev/blog)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
syntax error on line 0, col 21: `development: adapter: mysql encoding: utf8 database: blog_development pool: 5 username: root password: password socket: /tmp/mysql.sock '
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load'
C:/Ruby/lib/ruby/1.8/yaml.rb:133:in `load'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:880:in `database_configuration'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:4
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19

c:\rubydev\blog>

Here is the orginial yml file
# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
#   gem install mysql
# On Mac OS X:
#   sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
# On Mac OS X Leopard:
#   sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
#       This sets the ARCHFLAGS environment variable to your native architecture
# On Windows:
#   gem install mysql
#       Choose the win32 build.
#       Install MySQL and put its /bin directory on your path.
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: blog_development
  pool: 5
  username: root
  password:
  host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: blog_test
  pool: 5
  username: root
  password:
  host: localhost

production:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: blog_production
  pool: 5
  username: root
  password:
  host: localhost



Any suggestions?

Re: creating 1st web app - 500 error

flo23,

I gave that a try as well.

http://blog.emson.co.uk/2008/06/install … for-rails/

Step
gem install sqlite3--ruby=C:/Ruby/bin/ruby

This line fails
gem install sqlite3-ruby
c:\>gem install sqlite3-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe extconf.rb install sqlite3-ruby
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no
nmake
'nmake' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out


The results fo the log file (C:/Ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out)
C:/Ruby/bin/ruby.exe extconf.rb install sqlite3-ruby
checking for fdatasync() in rt.lib... no
checking for sqlite3.h... no

nmake
'nmake'
is not recognized as an internal or external command,
operable program or batch file.

Any suggestions?


Edit --
This worked
http://samdelacruz.blogspot.com/2008/11 … ls-on.html

Last edited by fwsteal (2009-06-15 11:43:20)

Re: creating 1st web app - 500 error

flo23, okay so I've done quite a bit to get the example to work on http://guides.rubyonrails.org/getting_started.html

What a lot of tricks.

So I then loaded up:

http://localhost:3000/app/blog

Got:
Routing Error

No route matches "/app/blog" with {:method=>:get}


As you mentioned earlier. How do I fix that error to see the blog?
error like "No route matches "/app/greeting" with {:method=>:get}", at least because you did not define a corresponding route (in config/routes.rb).

development log file:

Processing ApplicationController#index (for 127.0.0.1 at 2009-06-15 11:55:57) [GET]

ActionController::RoutingError (No route matches "/app/blog" with {:method=>:get}):
  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'

Rendering rescues/layout (not_found)

Re: creating 1st web app - 500 error

What have you got in your controller?

It also might be wise to use a different controller name, there's already an application controller, it can cause problems sometimes if you use names that might already be in use.

Why not just create a blog controller?  Add an index action to the controller and then you can see it at:
localhost:3000/blog

Last edited by Delameko (2009-06-15 13:35:50)

Re: creating 1st web app - 500 error

You may be starting to realise this, but doing web dev in Windows is a pain in the nuts.  I'd strongly recommend making a move to ubuntu linux for doing this.  You don't need to leave windows behind - you can set up ubuntu either as a virtual machine (using vmware) in which case it's effectively another OS running in a window inside Windows (this works better than you might expect).  Or, download the ubuntu installer and burn it onto a disc.  Boot your pc using that disc and linux can basically leave your Windows install as it is and just steal some hard drive space from it to install into.  Then you have a choice of booting into windows or linux.

It's a little bit of hassle now that will save you a ton of hassle later, trust me.  Most of the useful stuff you will want to do is done at the command line and the windows command line sucks. even if you install cygwin, which is kind of an approximation of the linux shell, it's not great.

I made the move about a year and a half ago when i started in rails and i love it now.

Last edited by Max Williams (2009-06-16 07:09:31)

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: creating 1st web app - 500 error

Max Williams wrote:

You may be starting to realise this, but doing web dev in Windows is a pain in the nuts.  I'd strongly recommend making a move to ubuntu linux for doing this.  You don't need to leave windows behind - you can set up ubuntu either as a virtual machine (using vmware) in which case it's effectively another OS running in a window inside Windows (this works better than you might expect).  Or, download the ubuntu installer and burn it onto a disc.  Boot your pc using that disc and linux can basically leave your Windows install as it is and just steal some hard drive space from it to install into.  Then you have a choice of booting into windows or linux.

It's a little bit of hassle now that will save you a ton of hassle later, trust me.  Most of the useful stuff you will want to do is done at the command line and the windows command line sucks. even if you install cygwin, which is kind of an approximation of the linux shell, it's not great.

I made the move about a year and a half ago when i started in rails and i love it now.

oh, and btw here's how you get sqlite3 running in linux:

sudo apt-get install sqlite3

that's it, in its entirety.  Here's how you get mysql installed:

sudo apt-get install mysql

Is it starting to look appealing yet?

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: creating 1st web app - 500 error

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

Re: creating 1st web app - 500 error

/!\ 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'

The above sounds like rails isn't accessing mysql as the root user, which it should do.  Post up the contents of your config/database.yml file.  I'm guessing it says

  username: prerna

where it should say

  username: root


Mine looks like this:

development:
  adapter: mysql
  database: e_learning_resource_trunk
  username: root

test:
  adapter: mysql
  database: e_learning_resource_trunk_test
  username: root
 
production:
  adapter: mysql
  database: e_learning_resource_trunk
  username: root

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: creating 1st web app - 500 error

Thank you for your reply. You are absolutely correct, the username that I have chosen is prerna, thinking that I can choose anything. Following is how my config/database.yml looks

development:
  adapter: mysql
  encoding: utf8
  database: library_development
  username: prerna
  password: library_development
  host: localhost
test:
  adapter: mysql
  encoding: utf8
  database: library_test
  username: prerna
  password: library_test
  host: localhost
production:
  adapter: mysql
  encoding: utf8
  database: library_production
  username: prerna
  password: library_production
  host:     localhost

Is it compulsory to use root as the username. And I wonder how your database.yml is missing on the host: encoding: etc. Could you plz tell me if I can remove these unnecessary things from my .yml too ?

Thanks again. I really appriciate your help.

Re: creating 1st web app - 500 error

localhost is the default host so it doesn't need to be specified.  Not sure about utf8 - it doesn't hurt to specify it anyway. 

The username doesn't have to be root, as such, but it needs to be the name of a user who has root priveleges, ie who can drop and create tables and so forth.  When it it set up, mysql has a default user with these priveleges, called 'root', and most people just use that.  You could use prerna but you'll need to make sure prerna has top-level priveleges.

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: creating 1st web app - 500 error

Now I might be asking a stupid question , but can you tell me how do I test that "prerna" has the top level privilleges ?

Re: creating 1st web app - 500 error

exploringror wrote:

Now I might be asking a stupid question , but can you tell me how do I test that "prerna" has the top level privilleges ?

google exists for stupid questions smile

show grants;

http://dev.mysql.com/doc/refman/5.1/en/grant.html

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams