What is wrong with my routes?
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
re开发者_运维百科sources :tattoos
end
Thats whats in my routes.rb file. They produce:
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"}
But i have a problem. For some reason, when I try to go to mysite.com/submit
I used to get this error
No route matches {:controller=>"images"}
on
<%= form_for @tattoo, :html =>{:multipart => true} do |f| %>
but that has magically changed to:
undefined method `images_path'
on the same line.
when my controller has this:
indexcontroller def new @tattoo = Image.new end
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
And then this link_to:
<%= link_to "Manage tattoos", member_tattoos_path() %>
give me this error:
No route matches {:controller=>"tattoos"}
I thought I was beginning to understand routes and had a decent grasp but I dont get whats going on!
You need to pass in a member object to edit_member_path
.
<%= link_to "Edit profile", edit_member_path(@member) %>
edit_member_path
should know the id of the member you want to edit. Please try
<%= link_to "Edit profile", edit_member_path(@member) %>
For No route matches {:controller=>"images"}
; since the action image is not defined in your route, please try to stop and restart the server and check if there is any plugin like Paperclip in place.
精彩评论