我是新來的鐵軌3(和鐵軌一般)...我建立了一個朋友樂隊的網站骨架,現在他想添加文章到他的網站...Rails 3.2.3路由錯誤(試圖添加文章)
到目前爲止,我建立的所有頁面都是:(主頁,節目,媒體,聯繫人)和標題&頁腳部分...因此沒有太花哨的東西。
繼承人我做了什麼添加文章至今:
rails g scaffold article title:string body:text
rake db:migrate
,但是當我去到本地主機:3000 /文章中,我得到這個錯誤信息:
ActionController::RoutingError in Articles#new
no route matches {:action=>"home", :controller=>"articles"}
它說錯誤是引發在應用程序/視圖/佈局/ _header.html.erb在線路#28:
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>
這裏是我的的routes.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
爲什麼我不能查看本地主機:3000 /文章? 任何有用的提示將是非常有責任的!
編輯:這裏是我的耙路線任務
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"}`
從* routes.rb *中刪除'resources:articles'會發生什麼? - 我也建議給你的路線命名,並在'link_to'中使用route_name_path,而不是動作的名字。 –
我試圖從_routes.rb_中刪除'resources:articles' ...現在我收到這個錯誤...'沒有路由匹配{:action =>「new」,:controller =>「articles」}'on _views /articles/index.html.erb_。有什麼建議麼? –