0

私は Rails 3 アプリを持っています。利用規約ページへのリンクをクリックすると、ルートが使用するものとはまったく異なるコントローラーにルーティングされます。まだ見知らぬ人ですが、ログインしていないときにルートが機能し、デバイスを使用しています。

ログイン中にリンクをクリックすると、このエラーが発生します。

No route matches {:action=>"edit", :controller=>"users", :id=>nil}

<%= link_to "Terms", terms_path %>

ルート (routes.rb に表示される順序で):

devise_for :users, :controllers => {:registrations => "registrations"}

resources :users do
  member do
    get :following, :followers
    post :accept
  end
end

match '/terms',     to: 'static_pages#user_agreement'

静的ページ コントローラー

def user_agreement

end

レーキルート

terms        /terms(.:format)                     static_pages#user_agreement

これは、この方法で staticpages コントローラーにルーティングした他のすべてのアクションでも発生しますが、別のコントローラーにルーティングする他のアクションでは発生しません。

更新: 規約ページのヘッダー:

<%= link_to "Follow", users_path %>
<%= link_to current_user.name, current_user %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>

フッター:

<%= link_to "Welcome", welcome_path %>
<%= link_to "Settings", edit_user_path(@user) %>
<%= link_to "Terms", terms_path %>

すべてのコンテンツは純粋な html です。

前もって感謝します

4

1 に答える 1

1

コメントで示唆されているようにedit_user_path、noへのリンクがあります。@user

current_userとにかく、ほぼ確実に使用する必要があります。

于 2013-05-21T18:35:07.173 に答える