View and Controller not working


#1

Hello,

I created a controller named animals and a .rhtml file called hello.

There is nothing in the controller, but there is “hello, world!” in
the .rhtml.

I booted up webbrick and typed “http://localhost:3000/animals/hello
and it should have displayed “hello, world!” instead it gave me this
error.

MissingSourceFile in AnimalsController#hello

no such file to load – sqlite3

Any ideas?

RAILS_ROOT: C:/InstantRails/rails_apps/view_demo
Application Trace | Framework Trace | Full Trace

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:inrequire’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:521:innew_constants_in’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ core_ext/kernel/requires.rb:7:inrequire_library_or_gem’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
core_ext/kernel/reporting.rb:11:in silence_warnings' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ core_ext/kernel/requires.rb:5:inrequire_library_or_gem’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/sqlite3_adapter.rb:10:in sqlite3_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:223:insend’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:223:in
new_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:245:incheckout_new_connection’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:188:in checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:184:inloop’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:184:in checkout' C:/Ruby/lib/ruby/1.8/monitor.rb:242:insynchronize’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:183:in checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:98:inconnection’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:326:in
retrieve_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:121:inretrieve_connection’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:113:in
connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ query_cache.rb:8:incache’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
caching/sql_cache.rb:12:in perform_action' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ base.rb:524:insend’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
base.rb:524:in process_without_filters' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ filters.rb:606:inprocess_without_session_management_support’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
session_management.rb:134:in process' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ base.rb:392:inprocess’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:183:in handle_request' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ dispatcher.rb:110:indispatch_unlocked’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:123:in dispatch' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ dispatcher.rb:122:insynchronize’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:122:in dispatch' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ dispatcher.rb:132:indispatch_cgi’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:39:in dispatch' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb: 103:inhandle_dispatch’
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:74:in
service' C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in start' C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in start' C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:ineach’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in start' C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:instart’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in start' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:60:indispatch’
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/
webrick.rb:66
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:inrequire’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:521:innew_constants_in’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49 C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
script/server:3

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:inrequire’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:521:innew_constants_in’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ core_ext/kernel/requires.rb:7:inrequire_library_or_gem’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
core_ext/kernel/reporting.rb:11:in silence_warnings' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ core_ext/kernel/requires.rb:5:inrequire_library_or_gem’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/sqlite3_adapter.rb:10:in sqlite3_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:223:insend’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:223:in
new_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:245:incheckout_new_connection’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:188:in checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:184:inloop’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:184:in checkout' C:/Ruby/lib/ruby/1.8/monitor.rb:242:insynchronize’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:183:in checkout' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_pool.rb:98:inconnection’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_pool.rb:326:in
retrieve_connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:121:inretrieve_connection’
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:113:in
connection' C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/ query_cache.rb:8:incache’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
caching/sql_cache.rb:12:in perform_action' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ base.rb:524:insend’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
base.rb:524:in process_without_filters' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ filters.rb:606:inprocess_without_session_management_support’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
session_management.rb:134:in process' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ base.rb:392:inprocess’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:183:in handle_request' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ dispatcher.rb:110:indispatch_unlocked’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:123:in dispatch' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ dispatcher.rb:122:insynchronize’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:122:in dispatch' C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/ dispatcher.rb:132:indispatch_cgi’
C:/Ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
dispatcher.rb:39:in dispatch' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb: 103:inhandle_dispatch’
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:74:in
service' C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
C:/Ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' C:/Ruby/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:in start' C:/Ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:95:in start' C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:ineach’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:92:in start' C:/Ruby/lib/ruby/1.8/webrick/server.rb:23:instart’
C:/Ruby/lib/ruby/1.8/webrick/server.rb:82:in start' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/webrick_server.rb:60:indispatch’
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/
webrick.rb:66
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:inrequire’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/ dependencies.rb:521:innew_constants_in’
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/
dependencies.rb:153:in require' C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49 C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
script/server:3

This error occurred while loading the following files:
sqlite3


#2

On Nov 24, 9:41 pm, “Mr. Watson” removed_email_address@domain.invalid wrote:

MissingSourceFile in AnimalsController#hello

Hey there. To create a basic, custom controller action, you need to do
three things:

  1. Create a method in the controller. In your case you’d need:
    class AnimalsController < ApplicationController
    def hello
    end
    end

  2. Create a view template for the action to render. In your case,
    you’d need app/views/animals/hello.html.erb .

  3. Create a route to the custom controller action. In your case, you’d
    need this in config/routes.rb :
    map.resources :animals, :collection => :hello

Since you’re getting started with Rails, I highly recommend reading
through Agile Web D. With Rails:
http://www.pragprog.com/titles/rails3/

Cheers,
Nick


#3

You have to configure Database in config/database.yml - and install
sqlite or mysql gem (db adapters, according to which db you want to
use).

But its obvious that the application you are building now doesnt
require any database, but rails needs a database connection by
default. So either create a dummy database for rails to connect to,

OR

In config/environment.rb, inside the Rails::Initializer block, add
this line:

config.frameworks -= [ :active_record ]