路由時:沒有路由匹配指定 '路徑'
resources :news_items, :path => 'news', :as => 'news' do
collection do
get 'all' => 'news_items#news'
end
控制器:
def new
@news = NewsItem.new
@news.file_uploads.build
respond_to do |format|
format.html # new.html.erb
format.json { render json: @news }
end
end
形式:
<%= form_for(@news, :html => {:class=>'form-stacked', :multipart => true}) do |f| %>
<% if @news.errors.any? %>
當運行耙路由
all_news_index GET /news/all(.:format) {:action=>"news", :controller=>"news_items"}
news_index GET /news(.:format) {:action=>"index", :controller=>"news_items"}
POST /news(.:format) {:action=>"create", :controller=>"news_items"}
new_news GET /news/new(.:format) {:action=>"new", :controller=>"news_items"}
edit_news GET /news/:id/edit(.:format) {:action=>"edit", :controller=>"news_items"}
news GET /news/:id(.:format) {:action=>"show", :controller=>"news_items"}
PUT /news/:id(.:format) {:action=>"update", :controller=>"news_items"}
DELETE /news/:id(.:format) {:action=>"destroy", :controller=>"news_items"}
當我去「/新聞/新」我得到:
No route matches {:path_prefix=>"news", :controller=>"news_items", :format=>nil}
當我去「/新聞/ 4 /編輯」我得到:
No route matches {:path_prefix=>"news", :action=>"show", :controller=>"news_items", :format=>nil, :id=>#<NewsItem id: 4,...
什麼是您的控制器調用,並在哪個文件駐留? – meagar 2012-01-05 18:29:11
@meagar NewsItemsController && news_items_controller.rb – LDK 2012-01-05 18:46:22