我是 rails 3 的新手(以及一般的 rails)...我为一个朋友乐队建立了一个网站骨架,现在他想在他的网站上添加文章...
到目前为止,我所构建的只是页面:(主页、节目、媒体、联系人)和页眉和页脚部分......所以还没有什么太花哨的东西。
到目前为止,这是我为添加文章所做的工作:
rails g scaffold article title:string body:text
rake db:migrate
但是当我访问 localhost:3000/articles 时,我收到以下错误消息:
ActionController::RoutingError in Articles#new
no route matches {:action=>"home", :controller=>"articles"}
它说错误是在第 28 行的 app/views/layouts/ _header.html.erb中引发的:
25: <h1>Title</h1>
26: <ul id="nav">
27: <ul>
28: <li><%= link_to image_tag("home.jpg",:class=> 'hoverImages'), :action => 'home' %></li>
29: <li><%= link_to image_tag("shows.jpg", :class=> 'hoverImages'), :action => 'shows' %></li>
30: <li><%= link_to image_tag("media.jpg", :class=> 'hoverImages'), :action => 'media' %></li>
31: <li><%= link_to image_tag("contact.jpg", :class=> 'hoverImages'), :action => 'contact' %></li>
这是我的路线.rb
CsmlSite::Application.routes.draw do
resources :articles
match '/shows', :to => 'pages#shows'
match '/media', :to => 'pages#media'
match '/contact', :to => 'pages#contact'
match '/articles', :to => 'articles#index'
root :to => "pages#home"
end
为什么我不能查看 localhost:3000/articles ?任何有用的提示都会非常感激!
编辑:这是我的rake route任务的输出
root /(.:format) {:controller=>"pages", :action=> "home"}
articles GET /articles(.:format) {:action=>"index", :controller=>"articles"}
POST /articles(.:format) {:action=>"create", :controller=>"articles"}
new_article GET /articles/new(.:format) {:action=>"new", :controller=>" articles"}
edit_article GET /articles/:id/edit(.:format) {:action=>"edit", :controller=>"articles"}
article GET /articles/:id(.:format) {:action=>"show", :controller=>"articles"}
PUT /articles/:id(.:format) {:action=>"update", :controller=>"articles"}
DELETE /articles/:id(.:format) {:action=>"destroy", :controller=>"articles"}
shows /shows(.:format) {:controller=>"pages", :action=>"shows"}
media /media(.:format) {:controller=>"pages", :action=>"media"}
contact /contact(.:format) {:controller=>"pages", :action=>"contact"}
contacts POST /contacts(.:format) {:action=>"create", :controller=>"contact_us/contacts"}
new_contact GET /contacts/new(.:format) {:action=>"new", :controller=>"contact_us/contacts"}
contact_us /contact_us(.:format) {:action=>"new", :controller=>"contact_us/contacts"}`