2012-02-11 42 views

Trả lời

7

Bạn phải phân lớp điều khiển như thế nào trong những điều sau đây:

class SessionsController < Devise::SessionsController 

    layout 'my_layout' 

end 

Và thay đổi các tuyến đường:

devise_for :users, :controllers => {:sessions => "sessions"} 
+0

Sau đó, tôi nhận được lỗi này: Mẫu bị thiếu Thiếu phiên mẫu/mới với. Tôi đã thay đổi thư mục xem theo dõi thành các phiên –

+0

Bạn phải thay đổi thư mục 'devise/sessions' thành' phiên '. – lucapette

2

Đầu tiên, thiết lập tuyến đường của bạn. Ví dụ:

devise_for :users, 
      :controllers => { 
         :registrations => "users/registrations", 
         :omniauth_callbacks => "users/omniauth_callbacks", 
         :sessions => "users/sessions"} 

Thứ hai, tạo ra các tập tin với bộ điều khiển:

class Users::SessionsController < Devise::SessionsController 
    layout=>"my_layout" 
end 

Thứ ba, tạo ra các quan điểm đối với điều khiển của bạn trong views/người/buổi. Ví dụ: new.html.haml

=form_for user=User.new, :as=>"user", :url=>session_path("user") do |f| 
    =f.label :email, 'email' 
    =f.text_field :email 
    =f.label :password, 'password' 
    =f.password_field :password 
    =link_to "Forgot your password?", new_password_path("user") 
    .button_container{:style=>'border-top: none;'} 
    =f.submit "sign in", :class=>'submit_button' 

Hy vọng trợ giúp này.

Các vấn đề liên quan