所以我尝试按照http://guides.spreecommerce.org/developer/authentication.html中的文档在我的Spree Rails应用上添加登录链接但是我无法在我的应用上获取该链接。
我在文档中添加以下代码到文件后创建了app / overrides / auth_login_bar.rb文件。
Deface::Override.new(:virtual_path => "spree/shared/_nav_bar",
:name => "auth_shared_login_bar",
:insert_before => "li#search-bar",
:partial => "spree/shared/login_bar",
:disabled => false,
:original => 'eb3fa668cd98b6a1c75c36420ef1b238a1fc55ad')
我还更新了config / routes.rb文件:
Rails.application.routes.draw do
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the :at option to something different.
#
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
mount Spree::Core::Engine, at: '/'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
devise_scope :person do
get '/login', :to => "devise/sessions#new"
get '/signup', :to => "devise/registrations#new"
delete '/logout', :to => "devise/sessions#destroy"
end
end
我似乎没有找到解决方法。
答案 0 :(得分:1)
如果您的应用程序是新的或您正在使用新的用户模型,请使用spree_auth_devise gem / extension,它将提供与所有狂欢版本兼容的所有用户级别身份验证。
答案 1 :(得分:1)
override
处的app/overrides/auth_login_bar.rb
文件告诉Spree将名为spree/shared/login_bar
的部分视图插入导航栏。您是否在视图中创建了此部分?
这是我的部分观点(用HAML编写),位于spree/shared/_login_bar.html.haml
- if spree_current_user
%li= link_to(Spree.t(:logout), destroy_spree_user_session_path, method: :delete)
- else
%li= link_to(Spree.t(:login), login_path)
%li= link_to(Spree.t(:signup), signup_path)
你也可以从第二行删除method: :delete
以使其成为get
请求,我认为现在是Spree的设置方式。