I am trying to add login/logout/sign up links to the front page of a solidus app. In the _login_bar_items partial I put this:
<% if spree_current_user %>
<li>
<%= link_to "Logout", destroy_spree_user_session_path, method: :delete %>
</li>
<% else %>
<li>
<%= link_to "Login", new_spree_user_session_path %>
</li>
<li>
<%= link_to "Register", new_spree_user_registration_path %>
</li>
<% end %>
And I get the error
No route matches [DELETE] "/user/spree_user/logout"
when I click on logout button. The paths are as displayed when I run rails routes
.
I also tried if current_user
but that didn't work either.
Any suggestions are appreciated.
Edit: Rails Routes output:
Prefix Verb URI Pattern Controller#Action
spree / Spree::Core::Engine
rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
Routes for Spree::Core::Engine:
new_spree_user_session GET /user/spree_user/sign_in(.:format) spree/user_sessions#new
spree_user_session POST /user/spree_user/sign_in(.:format) spree/user_sessions#create
destroy_spree_user_session GET /user/spree_user/logout(.:format) spree/user_sessions#destroy
new_spree_user_password GET /user/spree_user/password/new(.:format) spree/user_passwords#new
edit_spree_user_password GET /user/spree_user/password/edit(.:format) spree/user_passwords#edit
spree_user_password PATCH /user/spree_user/password(.:format) spree/user_passwords#update
PUT /user/spree_user/password(.:format) spree/user_passwords#update
POST /user/spree_user/password(.:format) spree/user_passwords#create
cancel_spree_user_registration GET /user/spree_user/cancel(.:format) spree/user_registrations#cancel
new_spree_user_registration GET /user/spree_user/sign_up(.:format) spree/user_registrations#new
edit_spree_user_registration GET /user/spree_user/edit(.:format) spree/user_registrations#edit
spree_user_registration PATCH /user/spree_user(.:format) spree/user_registrations#update
PUT /user/spree_user(.:format) spree/user_registrations#update
DELETE /user/spree_user(.:format) spree/user_registrations#destroy
POST /user/spree_user(.:format) spree/user_registrations#create
new_spree_user_confirmation GET /user/spree_user/confirmation/new(.:format) spree/user_confirmations#new
spree_user_confirmation GET /user/spree_user/confirmation(.:format) spree/user_confirmations#show
POST /user/spree_user/confirmation(.:format) spree/user_confirmations#create
edit_user GET /users/:id/edit(.:format) spree/users#edit
user PATCH /users/:id(.:format) spree/users#update
PUT /users/:id(.:format) spree/users#update
login GET /login(.:format) spree/user_sessions#new
create_new_session POST /login(.:format) spree/user_sessions#create
logout GET /logout(.:format) spree/user_sessions#destroy
signup GET /signup(.:format) spree/user_registrations#new
registration POST /signup(.:format) spree/user_registrations#create
recover_password GET /password/recover(.:format) spree/user_passwords#new
reset_password POST /password/recover(.:format) spree/user_passwords#create
edit_password GET /password/change(.:format) spree/user_passwords#edit
update_password PUT /password/change(.:format) spree/user_passwords#update
confirmation GET /confirm(.:format) spree/user_confirmations#show
checkout_registration GET /checkout/registration(.:format) spree/checkout#registration
update_checkout_registration PUT /checkout/registration(.:format) spree/checkout#update_registration
new_account GET /account/new(.:format) spree/users#new
edit_account GET /account/edit(.:format) spree/users#edit
account GET /account(.:format) spree/users#show
PATCH /account(.:format) spree/users#update
PUT /account(.:format) spree/users#update
DELETE /account(.:format) spree/users#destroy
POST /account(.:format) spree/users#create
admin_unauthorized GET /admin/authorization_failure(.:format) spree/admin/user_sessions#authorization_failure
admin_login GET /admin/login(.:format) spree/admin/user_sessions#new
admin_create_new_session POST /admin/login(.:format) spree/admin/user_sessions#create
admin_logout GET /admin/logout(.:format) spree/admin/user_sessions#destroy
admin_recover_password GET /admin/password/recover(.:format) spree/admin/user_passwords#new
admin_reset_password POST /admin/password/recover(.:format) spree/admin/user_passwords#create
admin_edit_password GET /admin/password/change(.:format) spree/admin/user_passwords#edit
admin_update_password PUT /admin/password/change(.:format) spree/admin/user_passwords#update
root GET / spree/home#index
products GET /products(.:format) spree/products#index
product GET /products/:id(.:format) spree/products#show
locale_set GET /locale/set(.:format) spree/locale#set
select_locale POST /locale/set(.:format) spree/locale#set
update_checkout PATCH /checkout/update/:state(.:format) spree/checkout#update
checkout_state GET /checkout/:state(.:format) spree/checkout#edit
checkout GET /checkout(.:format) spree/checkout#edit
orders_populate GET /orders/populate(.:format) spree/orders#populate_redirect
token_order GET /orders/:id/token/:token(.:format) spree/orders#show
populate_orders POST /orders/populate(.:format) spree/orders#populate
edit_order GET /orders/:id/edit(.:format) spree/orders#edit
order GET /orders/:id(.:format) spree/orders#show
PATCH /orders/:id(.:format) spree/orders#update
PUT /orders/:id(.:format) spree/orders#update
cart GET /cart(.:format) spree/orders#edit
update_cart PATCH /cart(.:format) spree/orders#update
empty_cart PUT /cart/empty(.:format) spree/orders#empty
nested_taxons GET /t/*id(.:format) spree/taxons#show
unauthorized GET /unauthorized(.:format) spree/home#unauthorized
cvv GET /content/cvv(.:format) spree/content#cvv
cart_link GET /cart_link(.:format) spree/store#cart_link
admin_search_users GET /admin/search/users(.:format) spree/admin/search#users
admin_search_products GET /admin/search/products(.:format) spree/admin/search#products
admin_set_locale PUT /admin/locale/set(.:format) spree/admin/locale#set {:format=>:json}
home_admin_dashboards GET /admin/dashboards/home(.:format) spree/admin/dashboards#home
admin_promotion_promotion_rules GET /admin/promotions/:promotion_id/promotion_rules(.:format) spree/admin/promotion_rules#index
POST /admin/promotions/:promotion_id/promotion_rules(.:format) spree/admin/promotion_rules#create
new_admin_promotion_promotion_rule GET /admin/promotions/:promotion_id/promotion_rules/new(.:format) spree/admin/promotion_rules#new
edit_admin_promotion_promotion_rule GET /admin/promotions/:promotion_id/promotion_rules/:id/edit(.:format) spree/admin/promotion_rules#edit
admin_promotion_promotion_rule GET /admin/promotions/:promotion_id/promotion_rules/:id(.:format) spree/admin/promotion_rules#show
PATCH /admin/promotions/:promotion_id/promotion_rules/:id(.:format) spree/admin/promotion_rules#update
PUT /admin/promotions/:promotion_id/promotion_rules/:id(.:format) spree/admin/promotion_rules#update
DELETE /admin/promotions/:promotion_id/promotion_rules/:id(.:format) spree/admin/promotion_rules#destroy
admin_promotion_promotion_actions GET /admin/promotions/:promotion_id/promotion_actions(.:format) spree/admin/promotion_actions#index
POST /admin/promotions/:promotion_id/promotion_actions(.:format) spree/admin/promotion_actions#create
new_admin_promotion_promotion_action GET /admin/promotions/:promotion_id/promotion_actions/new(.:format) spree/admin/promotion_actions#new
edit_admin_promotion_promotion_action GET /admin/promotions/:promotion_id/promotion_actions/:id/edit(.:format) spree/admin/promotion_actions#edit
admin_promotion_promotion_action GET /admin/promotions/:promotion_id/promotion_actions/:id(.:format) spree/admin/promotion_actions#show
PATCH /admin/promotions/:promotion_id/promotion_actions/:id(.:format) spree/admin/promotion_actions#update
PUT /admin/promotions/:promotion_id/promotion_actions/:id(.:format) spree/admin/promotion_actions#update
DELETE /admin/promotions/:promotion_id/promotion_actions/:id(.:format) spree/admin/promotion_actions#destroy
admin_promotion_promotion_codes GET /admin/promotions/:promotion_id/promotion_codes(.:format) spree/admin/promotion_codes#index
admin_promotion_promotion_code_batch_download GET /admin/promotions/:promotion_id/promotion_code_batches/:promotion_code_batch_id/download(.:format) spree/admin/promotion_code_batches#download {:format=>"csv"}
admin_promotion_promotion_code_batches GET /admin/promotions/:promotion_id/promotion_code_batches(.:format) spree/admin/promotion_code_batches#index
POST /admin/promotions/:promotion_id/promotion_code_batches(.:format) spree/admin/promotion_code_batches#create
new_admin_promotion_promotion_code_batch GET /admin/promotions/:promotion_id/promotion_code_batches/new(.:format) spree/admin/promotion_code_batches#new
admin_promotions GET /admin/promotions(.:format) spree/admin/promotions#index
POST /admin/promotions(.:format) spree/admin/promotions#create
new_admin_promotion GET /admin/promotions/new(.:format) spree/admin/promotions#new
edit_admin_promotion GET /admin/promotions/:id/edit(.:format) spree/admin/promotions#edit
admin_promotion GET /admin/promotions/:id(.:format) spree/admin/promotions#show
PATCH /admin/promotions/:id(.:format) spree/admin/promotions#update
PUT /admin/promotions/:id(.:format) spree/admin/promotions#update
DELETE /admin/promotions/:id(.:format) spree/admin/promotions#destroy
admin_promotion_categories GET /admin/promotion_categories(.:format) spree/admin/promotion_categories#index
POST /admin/promotion_categories(.:format) spree/admin/promotion_categories#create
new_admin_promotion_category GET /admin/promotion_categories/new(.:format) spree/admin/promotion_categories#new
edit_admin_promotion_category GET /admin/promotion_categories/:id/edit(.:format) spree/admin/promotion_categories#edit
admin_promotion_category PATCH /admin/promotion_categories/:id(.:format) spree/admin/promotion_categories#update
PUT /admin/promotion_categories/:id(.:format) spree/admin/promotion_categories#update
DELETE /admin/promotion_categories/:id(.:format) spree/admin/promotion_categories#destroy
admin_zones GET /admin/zones(.:format) spree/admin/zones#index
POST /admin/zones(.:format) spree/admin/zones#create
new_admin_zone GET /admin/zones/new(.:format) spree/admin/zones#new
edit_admin_zone GET /admin/zones/:id/edit(.:format) spree/admin/zones#edit
admin_zone GET /admin/zones/:id(.:format) spree/admin/zones#show
PATCH /admin/zones/:id(.:format) spree/admin/zones#update
PUT /admin/zones/:id(.:format) spree/admin/zones#update
DELETE /admin/zones/:id(.:format) spree/admin/zones#destroy
admin_tax_categories GET /admin/tax_categories(.:format) spree/admin/tax_categories#index
POST /admin/tax_categories(.:format) spree/admin/tax_categories#create
new_admin_tax_category GET /admin/tax_categories/new(.:format) spree/admin/tax_categories#new
edit_admin_tax_category GET /admin/tax_categories/:id/edit(.:format) spree/admin/tax_categories#edit
admin_tax_category GET /admin/tax_categories/:id(.:format) spree/admin/tax_categories#show
PATCH /admin/tax_categories/:id(.:format) spree/admin/tax_categories#update
PUT /admin/tax_categories/:id(.:format) spree/admin/tax_categories#update
Try with
<%= link_to "Logout", destroy_spree_user_session_path %>
because your "/user/spree_user/logout" is not defined as DELETE request but as GET request route.