Приятно, когда я непосредственно открываю 'http://localhost:3000/country.html' или нажимаю кнопку "Страна" на панели навигации. Но если я сначала нажму «Логин» / «Регистрация» (http://localhost:3000/users/signin.html), а затем нажму кнопку «Страна»), URL-ссылка на «http://localhost:3000/users/country.html'. покажет« Нет совпадений маршрутов [GET] »/ users /maison.html "". Более того, цвет "Логин" меняется на странный красный, который похож на общедоступную красную страницу "404" по умолчанию.
Может кто-нибудь сказать мне, почему разные последовательности кликов приведут к разным URL и как я могу выяснить проблему? Спасибо!
Это приложение, основанное на Ruby on Rail, с devise, ruby-2.3.7, 'rails', '~> 5.2.2' и mysql. Я использую macOS Mojave.
'''
'application.html.erb':
<div class="outside_container">
<div class="main_container">
<div class="navbar clearfix">
<div class="container">
<ul class="nav left">
<li><a href="./introduction.html">Introduction</a></li>
<li><a href="./country.html">Country</a></li>
<li><a href="./maison.html">Maison</a></li>
</ul>
<% if notice %>
<p class="notification"><%= notice %></p>
<% end %>
<% if alert %>
<p class="notification"><%= alert %></p>
<% end %>
<ul>
<p class="nav right">
<% if user_signed_in? %>
<%= link_to "Edit profile", edit_user_registration_path %> |
<%= link_to "Logout", destroy_user_session_path, method: :delete %> |
<% else %>
<%= link_to "Sign up", new_user_registration_path %> |
<%= link_to "Login", new_user_session_path %> |
<% end %>
</p>
</ul>
</div>
</div>
'''
извините за отсутствие route.rb, вот оно:
'Route.rb':
Rails.application.routes.draw do
devise_for :users
#make sure devise/session/new, which means the login page is the root page
devise_scope :user do
authenticated :user do
root 'country#index', as: :authenticated_root
end
unauthenticated do
root 'devise/sessions#new', as: :unauthenticated_root
end
end
get '/country', to: 'country#index'
get '/maison', to: 'maison#index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
#root 'page#welcome'
resources :country
resources :maison
resources :introduction
resources :dashboard
end