Commit 820aefcf by Đường Sỹ Hoàng

Fixed indentaion&double quote

parent d62fc6cd
...@@ -50,13 +50,13 @@ class UsersController < ApplicationController ...@@ -50,13 +50,13 @@ class UsersController < ApplicationController
def admin_user def admin_user
redirect_to(root_url) unless current_user.admin? redirect_to(root_url) unless current_user.admin?
end end
def user_params def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation) params.require(:user).permit(:name, :email, :password, :password_confirmation)
end end
# Before filters # Before filters
user
# Confirms a logged-in user. # Confirms a logged-in user.
def logged_in_user def logged_in_user
unless logged_in? unless logged_in?
...@@ -71,7 +71,5 @@ class UsersController < ApplicationController ...@@ -71,7 +71,5 @@ class UsersController < ApplicationController
@user = User.find(params[:id]) @user = User.find(params[:id])
redirect_to(root_url) unless current_user?(@user) redirect_to(root_url) unless current_user?(@user)
end end
end end
module UsersHelper module UsersHelper
# Returns the Gravatar for the given user. # Returns the Gravatar for the given user.
def gravatar_for(user,options={ size: 80}) def gravatar_for(user, options = { size: 80 })
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
size = options[:size] size = options[:size]
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
......
<!-- <% provide(:title, "Edit user") %> <% provide(:title, "Edit user") %>
<% provide(:button_text, "Save changes") %>
<h1>Update your profile</h1> <h1>Update your profile</h1>
<div class="row"> <div class="row">
<div class="col-md-6 col-md-offset-3"> <div class="col-md-6 col-md-offset-3">
<%= form_for(@user) do |f| %> <%= render "form" %>
<%= render "shared/error_messages" %>
<%= f.label :name %>
<%= f.text_field :name, class: "form-control" %>
<%= f.label :email %>
<%= f.email_field :email, class: "form-control" %>
<%= f.label :password %>
<%= f.password_field :password, class: "form-control" %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation, class: "form-control" %>
<%= f.submit "Save changes", class: "btn btn-primary" %>
<% end %>
<div class="gravatar_edit">
<%= gravatar_for @user %>
<a href="http://gravatar.com/emails" target="_blank">change</a>
</div>
</div>
</div> -->
<% provide(:title, 'Edit user') %>
<% provide(:button_text, 'Save changes') %>
<h1>Update your profile</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= render 'form' %>
<div class="gravatar_edit"> <div class="gravatar_edit">
<%= gravatar_for @user %> <%= gravatar_for @user %>
<a href="http://gravatar.com/emails" target="_blank">Change</a> <a href="http://gravatar.com/emails" target="_blank">Change</a>
......
...@@ -4,4 +4,4 @@ name = Faker::Name.name ...@@ -4,4 +4,4 @@ name = Faker::Name.name
email = "example-#{n+1}@railstutorial.org" email = "example-#{n+1}@railstutorial.org"
password = "password" password = "password"
User.create!(name: name,email: email,password:password,password_confirmation: password) User.create!(name: name,email: email,password:password,password_confirmation: password)
end end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment