我是铁杆新手,我跟着“先用铁轨前往”这本书。
这是我所做的步骤:
$rails tickets
shaun@master ~/Desktop/tickets $ rails generate scaffold ticket name:string seat_id_seg:string address:text price_paid:decimal email_address:string
shaun@master ~/Desktop/tickets $ rake routes
tickets GET /tickets(.:format) tickets#index
POST /tickets(.:format) tickets#create
new_ticket GET /tickets/new(.:format) tickets#new
edit_ticket GET /tickets/:id/edit(.:format) tickets#edit
ticket GET /tickets/:id(.:format) tickets#show
PUT /tickets/:id(.:format) tickets#update
DELETE /tickets/:id(.:format) tickets#destroy
shaun@master ~/Desktop/tickets $ rake db:migrate
== CreateTickets: migrating ==================================================
-- create_table(:tickets)
-> 0.1065s
== CreateTickets: migrated (0.1069s) =========================================
when i try going to localhost:3000/tickets
it comes out Routing Error and says "No route matches [GET] "/tickets"
> Started GET "/tickets" for 192.168.1.8 at Thu Jul 12 08:45:38 +0800 2012
Connecting to database specified by database.yml
ActionController::RoutingError (No route matches [GET] "/tickets"):
actionpack (3.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.6) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.6) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.6) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.6) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.6) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.6) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.6) lib/rails/engine.rb:479:in `call'
railties (3.2.6) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.6) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `each'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.4.1) lib/rack/handler/webrick.rb:13:in `run'
rack (1.4.1) lib/rack/server.rb:265:in `start'
railties (3.2.6) lib/rails/commands/server.rb:70:in `start'
railties (3.2.6) lib/rails/commands.rb:55
railties (3.2.6) lib/rails/commands.rb:50:in `tap'
railties (3.2.6) lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6
Rendered /var/lib/gems/1.8/gems/actionpack-3.2.6/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (2.8ms)
我该如何解决这个问题?我希望能够看到主页面和所有链接去索引,创建新票证,编辑,显示,更新和删除。
答案 0 :(得分:2)
我就像你为新的Rails 3.2.6应用程序编写的那样,它对我来说很好。您错过的唯一一步是在您的脚手架生成后运行rake db:migrate
。试试看,看看它是否有效。