root :to => "index#home"
#public tattoo viewing and submissions
match "/submit" => "index#new", :via => :get
match "/tattoo" => "index#create", :via => :post
match "/tattoo/:id" => "index#show", :via => :get
match "/tagged" => "index#tagged", :via => :get
match "/tattoo/:id" => "index#destroy", :via => :delete
match "/tattoos" => "index#index", :via => :get
members section and its nested images
resources :members, :except => [:new, :create] do
resources :tattoos
end
这是我的routes.rb文件中的内容。他们生产:
root /(.:format) {:controller=>"index", :action=>"home"}
submit GET /submit(.:format) {:controller=>"index", :action=>"new"}
tattoo POST /tattoo(.:format) {:controller=>"index", :action=>"create"}
GET /tattoo/:id(.:format) {:controller=>"index", :action=>"show"}
tagged GET /tagged(.:format) {:controller=>"index", :action=>"tagged"}
DELETE /tattoo/:id(.:format) {:controller=>"index", :action=>"destroy"}
tattoos GET /tattoos(.:format) {:controller=>"index", :action=>"index"}
members GET /members(.:format) {:action=>"index", :controller=>"members"}
edit_member GET /members/:id/edit(.:format) {:action=>"edit", :controller=>"members"}
member GET /members/:id(.:format) {:action=>"show", :controller=>"members"}
PUT /members/:id(.:format) {:action=>"update", :controller=>"members"}
DELETE /members/:id(.:format) {:action=>"destroy", :controller=>"members"}
但我有一个问题。出于某种原因,当我尝试去mysite.com/submit
时我曾经遇到过这个错误
No route matches {:controller=>"images"}
在
<%= form_for @tattoo, :html =>{:multipart => true} do |f| %>
但是神奇地改为:
undefined method `images_path'
在同一条线上。
当我的控制器有这个:
的IndexController def new @tattoo = Image.new 端
def create
@tattoo = Image.new(params[:image])
if @tattoo.save
flash[:success] = "Tattoo sent in for approval!"
redirect_to(images_path)
else
render :action => "new"
end
end
然后这个link_to:
<%= link_to "Manage tattoos", member_tattoos_path() %>
给我这个错误:
No route matches {:controller=>"tattoos"}
我以为我已经开始了解路线并且掌握得很好但是我不知道最新情况!
答案 0 :(得分:2)
您需要将成员对象传递给edit_member_path
。
<%= link_to "Edit profile", edit_member_path(@member) %>
答案 1 :(得分:1)
edit_member_path
应该知道您要编辑的成员的ID。请尝试
<%= link_to "Edit profile", edit_member_path(@member) %>
No route matches {:controller=>"images"}
;由于行动图像未在您的路线中定义,请尝试停止并重新启动服务器并检查是否有任何插件如Paperclip。