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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rails doesn''t "automagically" make an interface for you. Perhaps what you''re looking for is something like "script/generate scaffold <model> <controller>" "script/generate scaffold_resource <model>" or ActiveScaffold. Thufir wrote:> 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 > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thufir wrote:> 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. >The *rails* command makes your new rails project in a folder. CD into your new project (a folder rails_apps) and do a scaffold command, for each model and controller you want, which does the CRUD of model, controller, and the views. :) don''t forget the database table for a model (if you are doing this) should have a field called ''id'' and is auto incrementened and a primary key field. some of these other dudes are better at this then me. read what they write. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Nov 27, 4:34 pm, Ryan <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rails doesn''t "automagically" make an interface for you. Perhaps what > you''re looking for is something like "script/generate scaffold <model> > <controller>" "script/generate scaffold_resource <model>" or ActiveScaffold.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 :) -Thufir --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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:> Thufir wrote: > >> 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. >> >> > > The *rails* command makes your new rails project in a folder. > > CD into your new project (a folder rails_apps) and do a scaffold > command, for each model and controller you want, which does the CRUD of > model, controller, and the views. :) > > don''t forget the database table for a model (if you are doing this) > should have a field called ''id'' and is auto incrementened and a primary > key field. > > some of these other dudes are better at this then me. read what they > write. >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That was really frustrating, but now it works. I don''t fully
understand it, but at least it gives me the expected results :)
I can go to <http://localhost:3000/feeds> and enter data into the
feeds table, and go to <http://localhost:3000/categories> and enter
data into the categories table! I have no idea how it really works,
nor do I have any idea as to how to do inheritance, mixins, one-to-
many relationships, nor much of anything else.
For me, the default interface is fine for now :)
For the record I just had my scaffold generation off:
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)
################################################
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")
system("script/generate migration categories")
##################################################
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
################################################
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 :parent_id, integer
table.column :title, text
end
end
def self.down
drop_table :categories
end
end"
_002_categories.close
########################################3
system("rake db:migrate VERSION=0")
system("rake db:migrate")
##########################################
system("script/generate scaffold feed")
system("script/generate scaffold category")
##### start the WEBrick server
puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
puts "\t\t\thttp://localhost:3000/feeds"
puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
system("script/server")
thufir@arrakis ~/rubyCode $
thanks,
Thufir
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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)
################################################
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")
system("script/generate migration categories")
##################################################
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
################################################
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 :prnt_num, :integer
table.column :title, :string
end
end
def self.down
drop_table :categories
end
end"
_002_categories.close
########################################3
system("rake db:migrate VERSION=0")
system("rake db:migrate")
##########################################
system("script/generate scaffold feed")
system("script/generate scaffold category")
##### start the WEBrick server
puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
puts "\t\t\thttp://localhost:3000/feeds"
puts "\t\t\thttp://localhost:3000/categories"
puts "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
system("script/server")
thufir@arrakis ~/rubyCode $
thanks,
Thufir
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Wed, 28 Nov 2007 11:04:23 +1030, Ryan wrote:> Rails doesn''t "automagically" make an interface for you. Perhaps what > you''re looking for is something like "script/generate scaffold <model> > <controller>" "script/generate scaffold_resource <model>" or > ActiveScaffold.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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---