generating CRUD interface automagically

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.

I'm not entirely sure why it's broken, but this appears to be cause,
however I'm not clear as to what the solution is:

thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cat straw/config/routes.rb
ActionController::Routing::Routes.draw do |map|
  # The priority is based upon order of creation: first created ->
highest priority.

  # Sample of regular route:
  # map.connect 'products/:id', :controller => 'catalog', :action =>
'view'
  # Keep in mind you can assign values other than :controller
and :action

  # Sample of named route:
  # map.purchase 'products/:id/purchase', :controller =>
'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # You can have the root of your site routed by hooking up ''
  # -- just remember to delete public/index.html.
  # map.connect '', :controller => "welcome"

  # Allow downloading Web Service WSDL as a file with an extension
  # instead of a file named 'wsdl'
  map.connect ':controller/service.wsdl', :action => 'wsdl'

  # Install the default route as the lowest priority.
  map.connect ':controller/:action/:id.:format'
  map.connect ':controller/:action/:id'
end
thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ date
Tue Nov 27 16:11:03 PST 2007
thufir@arrakis ~/rubyCode $

thanks,

Thufir

According to the screenshots and tutorial at <http://
developer.apple.com/tools/rubyonrails.html> it does create a CRUD
interface (at least that's my take on it).

Thank you for the scaffold information, I'll try it :slight_smile:

-Thufir

You can also add:

scaffold :model

to the top of the controller (:model being the name of the model you
want the crud interface for). I believe this is the magic you are
referring to. Just be aware that this form of scaffolding is going away
in rails 2.0 in favor of the scaffold generator the others have posted.

-Bill

Trent Black wrote:

I fixed the scaffold command(s), phew!

pretty neat, a decent interface for data entry. I'm kinda torn, I
want to do some one-to-many relations, see how polymorphism works in
rails, etc, etc. Another part of me wants to work on what was the
impetus for this whole thing: an RSS aggregator.

In any event, here's what I have, and I can say that it works:

thufir@arrakis ~/rubyCode $
thufir@arrakis ~/rubyCode $ cat straw.rb
require 'fileutils'
require "mysql"

dbname = "straw_development"
m = Mysql.new("localhost", "root", "")
r = m.query("DROP DATABASE IF EXISTS #{dbname}")
r = m.query("CREATE DATABASE #{dbname}")
m.select_db(dbname)
m.query("CREATE TABLE dummy
        (
        id integer)")
m.close

FileUtils.rmtree 'straw'
system("rails straw")
FileUtils.cd('straw', :verbose => true)

What I ended up doing was "script/generate scaffold <model>" once for
each model (I have two tables). This gives CRUD access to the flat
tables. I suppose that "script/generate scaffold <model> <controller>"
is used for relationships?

thanks,

Thufir