Commit d918dc16 by Đường Sỹ Hoàng

Removed unuse file

parent 5ad6e140
...@@ -9,12 +9,13 @@ class UsersController < ApplicationController ...@@ -9,12 +9,13 @@ class UsersController < ApplicationController
def show def show
@user = User.find(params[:id]) @user = User.find(params[:id])
redirect_to root_url and return unless @user.activated
@microposts = @user.microposts.paginate(page: params[:page]) @microposts = @user.microposts.paginate(page: params[:page])
end end
def new def new
@user = User.new @user = User.new
end end
def create def create
@user = User.new(user_params) @user = User.new(user_params)
...@@ -71,17 +72,6 @@ class UsersController < ApplicationController ...@@ -71,17 +72,6 @@ class UsersController < ApplicationController
params.require(:user).permit(:name, :email, :password, :password_confirmation) params.require(:user).permit(:name, :email, :password, :password_confirmation)
end end
# Before filters
# Confirms a logged-in user.
def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Please log in."
redirect_to login_url
end
end
# Confirms the correct user. # Confirms the correct user.
def correct_user def correct_user
@user = User.find(params[:id]) @user = User.find(params[:id])
......
...@@ -12,9 +12,9 @@ class Micropost < ApplicationRecord ...@@ -12,9 +12,9 @@ class Micropost < ApplicationRecord
private private
# Validates the size of an uploaded picture. # Validates the size of an uploaded picture.
def picture_size def picture_size
if picture.size > 5.megabytes if picture.size > 5.megabytes
errors.add(:picture, "should be less than 5MB") errors.add(:picture, "should be less than 5MB")
end
end end
end
end end
...@@ -24,7 +24,7 @@ class User < ApplicationRecord ...@@ -24,7 +24,7 @@ class User < ApplicationRecord
has_secure_password has_secure_password
class << self class << self
# Returns the hash digest of the given string. # Returns the hash digest of the given string.
def digest(string) def digest(string)
cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost
BCrypt::Password.create(string, cost: cost) BCrypt::Password.create(string, cost: cost)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<span class="timestamp"> <span class="timestamp">
Posted <%= time_ago_in_words(micropost.created_at) %> ago. Posted <%= time_ago_in_words(micropost.created_at) %> ago.
<% if current_user?(micropost.user) %> <% if current_user?(micropost.user) %>
<%= link_to "delete", micropost, method: :delete, data: { confirm: "You sure?" } %> <%= link_to "delete", micropost, method: :delete, data: { confirm: "You sure?" } %>
<% end %> <% end %>
</span> </span>
</li> </li>
...@@ -3,27 +3,10 @@ ...@@ -3,27 +3,10 @@
<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", object: f.object %> <div class="gravatar_edit">
<%= gravatar_for @user %>
<%= f.label :name %> <a href="http://gravatar.com/emails">change</a>
<%= 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">change</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -3,17 +3,6 @@ ...@@ -3,17 +3,6 @@
<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", object: f.object %>
<%= 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 "Create my account", class: "btn btn-primary" %>
<% end %>
</div> </div>
</div> </div>
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