Skip to content

User microposts#14

Open
nghiadk1102 wants to merge 1 commit intomasterfrom
user-microposts
Open

User microposts#14
nghiadk1102 wants to merge 1 commit intomasterfrom
user-microposts

Conversation

@nghiadk1102
Copy link
Owner

No description provided.

@nghiadk1102 nghiadk1102 force-pushed the user-microposts branch 2 times, most recently from 186c4ee to 12b6c86 Compare July 3, 2017 02:14
@nghiadk1102
Copy link
Owner Author

ready

return if logged_in?
store_location
flash[:danger] = t ".please_login"
redirect_to login_url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix all indent from line 8-11

before_action :correct_user, only: :destroy

def create
@micropost = current_user.microposts.build micropost_params

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thêm 1 dòng trống phía dưới

def correct_user
@micropost = current_user.microposts.find_by id: params[:id]
redirect_to root_url if @micropost.nil?
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix all indent from line 24-31

@@ -0,0 +1,2 @@
module MicropostsHelper

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File này chưa dùng đến bạn xóa đi nhé

class Micropost < ApplicationRecord
belongs_to :user

default_scope -> {order created_at: :desc}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bạn viết 1 scope để dùng chứ không dùng default_scope như này nhé

validates :user_id, presence: true
validates :content, presence: true,
length: {maximum: Settings.model.microposts.size_post}
validate :picture_size

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thừa khoảng trắng: => validate :picture_size

class PictureUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick

process resize_to_limit: [400, 400]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move 400 into Settings

@@ -0,0 +1,19 @@
<%= form_for(@micropost) do |f| %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ()

</span>
<% end %>

<script type="text/javascript">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this code javascript into file .js

<div class="col-md-8">
<% if @user.microposts.any? %>
<h3>
<%= t ".micopost" %>(<%= @user.microposts.count %>)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ở đây có đang chọc vào db từ view không nhỉ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

không ạ, biến @user đã được định nghĩa tại controller rồi ạ, nên dữ liệu tại đây là do controller truyền đến

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bạn tìm hiểu điểm giống và khác nhau giữa: count, size vs length nhé

@huongnguyenmta
Copy link

commented

@nghiadk1102 nghiadk1102 force-pushed the user-microposts branch 2 times, most recently from 854ebde to f0cb72c Compare July 4, 2017 01:34
@nghiadk1102
Copy link
Owner Author

ready

@huongnguyenmta
Copy link

commented

@nghiadk1102
Copy link
Owner Author

ready

@@ -0,0 +1,8 @@
$(document).ready(function(){
$("#micropost_picture").bind("change", function() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$("#micropost_picture").change() được không, bind() cũ rồi 😁

class Micropost < ApplicationRecord
belongs_to :user

scope :time_desc, -> {order created_at: :desc}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

->{order created_at: :desc}

@lamhh26
Copy link

lamhh26 commented Jul 4, 2017

commented

@nghiadk1102
Copy link
Owner Author

ready

@dieunb
Copy link

dieunb commented Jul 5, 2017

merged-ignore thư mục public/uploads đi nhé

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants