2011-08-13 19 views
1
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 デフ新しい @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"} 

私はルートを理解し始めていて、まともな把握力があると思っていましたが、何が起こっているのかわかりません!

答えて

1

edit_member_pathは、編集するメンバーのIDを知っている必要があります。試してみてください

<%= link_to "Edit profile", edit_member_path(@member) %> 

No route matches {:controller=>"images"}については、あなたのルートにアクションイメージが定義されていないので、サーバーを停止して再起動して、Paperclipのようなプラグインがあるかどうか確認してください。

+1

現在のユーザーが自分のプロフィールを編集できるページへのリンクを持っていることを望んでいたので、link_toを<%= link_to "プロフィールの編集"、edit_member_path(current_user)%> – rugbert

+0

に変更しました。私はその仕事がうれしいです。 – lbz

2

会員オブジェクトをedit_member_pathに渡す必要があります。

<%= link_to "Edit profile", edit_member_path(@member) %> 
関連する問題