When I browse to http://localhost:3000/feeds I expect rails to
“automagically” present a CRUD interface because I’ve done this with a
previous rails (tutorial) project. It’s like I’m missing a rake
command,
or a scaffold or migration command. I think that what presents the
view would be an action? The action uses a controller?
However, I’m not sure and that’s a bit of a shot in the dark.
Instead of the expected CRUD interfact to the table “feeds” I get the
following error:
Routing Error
no route found to match “/feeds” with {:method=>:get}
The title of this page is “Action Controller: Exception caught,” which
indicates that my intuition/vague recollection about this being related
to an action is on target – but I’m not positive.
Here’s what I’m doing to generate the above error:
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ mysql --user=root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>
mysql> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| feed_on_feeds |
| mysql |
| test |
±-------------------+
4 rows in set (0.00 sec)
mysql> create database straw_development;
Query OK, 1 row affected (0.00 sec)
mysql> quit
Bye
thufir@arrakis ~/rubyCode $ ruby straw.rb
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create components
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create script/process
create test/fixtures
create test/functional
create test/integration
create test/mocks/development
create test/mocks/test
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.rb
create app/helpers/application_helper.rb
create test/test_helper.rb
create config/database.yml
create config/routes.rb
create public/.htaccess
create config/boot.rb
create config/environment.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/breakpointer
create script/console
create script/destroy
create script/generate
create script/performance/benchmarker
create script/performance/profiler
create script/process/reaper
create script/process/spawner
create script/process/inspector
create script/runner
create script/server
create script/plugin
create public/dispatch.rb
create public/dispatch.cgi
create public/dispatch.fcgi
create public/404.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
cd straw
create db/migrate
create db/migrate/001_feeds.rb
exists db/migrate
create db/migrate/002_categories.rb
(in /home/thufir/rubyCode/straw)
(in /home/thufir/rubyCode/straw)
== Feeds: migrating
– create_table(:feeds)
→ 0.0294s
== Feeds: migrated (0.0300s)
== Categories: migrating
– create_table(:categories)
→ 0.0097s
== Categories: migrated (0.0103s)
exists app/controllers/
exists app/helpers/
create app/views/straw
exists app/views/layouts/
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
create app/models/feed.rb
create test/unit/feed_test.rb
create test/fixtures/feeds.yml
create app/views/straw/_form.rhtml
create app/views/straw/list.rhtml
create app/views/straw/show.rhtml
create app/views/straw/new.rhtml
create app/views/straw/edit.rhtml
create app/controllers/straw_controller.rb
create test/functional/straw_controller_test.rb
create app/helpers/straw_helper.rb
create app/views/layouts/straw.rhtml
create public/stylesheets/scaffold.css
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
http://localhost:3000/feeds
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
=> Booting WEBrick…
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2007-11-27 14:34:25] INFO WEBrick 1.3.1
[2007-11-27 14:34:25] INFO ruby 1.8.6 (2007-09-24) [i686-linux]
[2007-11-27 14:34:25] INFO WEBrick::HTTPServer#start: pid=8040
port=3000
127.0.0.1 - - [27/Nov/2007:14:34:35 PST] “GET /feeds HTTP/1.1” 404 619
- → /feeds
[2007-11-27 14:34:45] INFO going to shutdown …
[2007-11-27 14:34:45] INFO WEBrick::HTTPServer#start done.
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ mysql --user=root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.44-log Gentoo Linux mysql-5.0.44
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql> show tables from straw_development;
±----------------------------+
| Tables_in_straw_development |
±----------------------------+
| categories |
| feeds |
| schema_info |
±----------------------------+
3 rows in set (0.00 sec)
mysql> quit
Bye
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cat straw.rb
#kludgy and brittle, but runs without errors on gentoo
#may or may not work on windows
#assumes MySQL is installed
why doesn’t http://localhost:3000/feeds bring up the db?
require ‘fileutils’
FileUtils.rmtree ‘straw’
system(“rails straw”)
FileUtils.cd(‘straw’, :verbose => true)
FileUtils.rm ‘config/database.yml’, :force => true
database_yml = File.open(‘config/database.yml’, ‘w’)
database_yml.puts "
development:
adapter: mysql
database: straw_development
username: root
password:
host: localhost
socket: /var/run/mysqld/mysqld.sock
test:
adapter: mysql
database: straw_test
username: root
password:
host: localhost
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql
database: straw_production
username: root
password:
host: localhost
socket: /var/run/mysqld/mysqld.sock"
database_yml.close
system(“script/generate migration feeds”)
FileUtils.rm ‘db/migrate/001_feeds.rb’, :force => true
_001_feeds = File.open(‘db/migrate/001_feeds.rb’, ‘w’)
_001_feeds.puts "
class Feeds < ActiveRecord::Migration
def self.up
create_table :feeds do |table|
table.column :title, :string
table.column :location, :string
table.column :category_id, :integer
end
end
def self.down
drop_table :feeds
end
end"
_001_feeds.close
##########categories
system(“script/generate migration categories”)
FileUtils.rm ‘db/migrate/002_categories.rb’, :force => true
_002_categories = File.open(‘db/migrate/002_categories.rb’, ‘w’)
_002_categories.puts "
class Categories < ActiveRecord::Migration
def self.up
create_table :categories do |table|
table.column :title, :string
table.column :parent_id, :integer
table.column :category_id, :integer
end
end
def self.down
drop_table :categories
end
end"
_002_categories.close
system(“rake db:migrate VERSION=0”)
system(“rake db:migrate”)
system(“script/generate scaffold feed straw”)
start the WEBrick server
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”
puts “\t\t\thttp://localhost:3000/feeds”
puts “@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@”
system(“script/server”)
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cat /etc/gentoo-release
Gentoo Base System release 1.12.9
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ date
Tue Nov 27 14:35:44 PST 2007
thufir@arrakis ~/rubyCode $
thanks,
Thufir