Montag, 12. August 2013

Remember and Reset Password and use of Draper

Today I have continued Remember and Reset Password. I achieved reset the password and the remember password in Sign Up and Log In pages. (The problem No route matches [PUT] "/password_resets.tyubOZQQExHjqqOSfMRqAw" was a silly typo error)

Also, very interesting. I use simple_for for the log_in form (I am not using an object for the model for the form, instead I am using the symbol :log_in)

<%= simple_form_for :log_in, { url: sessions_path } do |f| %>
  <%= f.input :email %>
  <%= f.input :password %>
  <%= f.input :remember_me, as: :boolean, input_html: { checked: true } %>
  <p><%= link_to "forgotten password?", new_password_reset_path %></p>
  <%= f.button :submit, "Log in" %>
<% end %>

So, to use the params in the controller I needed to use params[:log_in]. An example:

user = User.authenticate(params[:log_in][:email], params[:log_in][:password])

After that, I followed the steps in Draper railscasts. I think that the version in the Railscasts is older than the one I used, because I had to make some changes.

Finally, I pushed every change in the repository.

Good night!!






Keine Kommentare:

Kommentar veröffentlichen