-
Notifications
You must be signed in to change notification settings - Fork 0
Lydia/wri 13 image upload #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: remove-editor.js
Are you sure you want to change the base?
Changes from all commits
06de7da
17820fe
b604df9
67cc0fb
124aa10
d795d37
c9ae813
60767d0
01a1a96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,7 @@ def show | |
if @post.draft? | ||
redirect_to edit_post_path(@post) | ||
end | ||
if current_user.nil? || @post.user != current_user | ||
ahoy.track "post viewed", post_id: @post.id | ||
end | ||
ahoy.track "post viewed", post_id: @post.id | ||
end | ||
|
||
# GET /posts/new | ||
|
@@ -66,7 +64,7 @@ def update | |
respond_to do |format| | ||
if @post.update(post_params) | ||
format.turbo_stream {} | ||
format.html {redirect_to post_path(@post)} | ||
format.html {redirect_to root_path} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The redirect path after updating a post has been changed to the root path. Consider changing it back to |
||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @post.errors, status: :unprocessable_entity } | ||
|
@@ -113,7 +111,7 @@ def set_post | |
|
||
# Only allow a list of trusted parameters through. | ||
def post_params | ||
post_params = params.require(:post).permit(:body, :title, :draft_body, :publication_id) | ||
post_params = params.require(:post).permit(:body, :title, :draft_body, :publication_id, images:[]) | ||
|
||
if post_params[:publication_id].present? | ||
post_params[:publication_id] = post_params[:publication_id].to_i.zero? ? nil : post_params[:publication_id].to_i | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,26 @@ | |
# index_users_on_invited_by_id (invited_by_id) | ||
# index_users_on_reset_password_token (reset_password_token) UNIQUE | ||
# | ||
# reset_password_sent_at :datetime | ||
# reset_password_token :string | ||
# sign_in_count :integer default(0), not null | ||
# timezone :string default("UTC") | ||
# uid :string | ||
# unconfirmed_email :string | ||
# username :string | ||
# website :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# invited_by_id :bigint | ||
# | ||
# Indexes | ||
# | ||
# index_users_on_email (email) UNIQUE | ||
# index_users_on_invitation_token (invitation_token) UNIQUE | ||
# index_users_on_invited_by (invited_by_type,invited_by_id) | ||
# index_users_on_invited_by_id (invited_by_id) | ||
# index_users_on_reset_password_token (reset_password_token) UNIQUE | ||
# | ||
class User < ApplicationRecord | ||
# Include default devise modules. Others available are: | ||
# :confirmable, :lockable, :timeoutable, :trackable and | ||
|
@@ -134,7 +154,7 @@ def pending_acceptance? | |
end | ||
|
||
def visited_posts | ||
post_ids = Ahoy::Event.where(user_id: id , name: "post viewed").order(time: :desc).pluck(Arel.sql("properties ->> 'post_id'")) | ||
post_ids = Ahoy::Event.where(user_id: 2 , name: "post viewed").order(time: :desc).pluck(Arel.sql("properties ->> 'post_id'")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user_id for the Ahoy::Event.where query is hardcoded to 2. Consider replacing it with the id of the current user. |
||
Post.with_discarded.where(id: post_ids).where(discarded_at: nil) | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
= simple_form_for comment, url: comments_path do |f| | ||
= f.input :body, as: :text, maxlength: 1000,label: false, input_html:{rows: 5, class: 'block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm'}, placeholder: "Write a comment...", required: true | ||
= f.input :body, as: :text, maxlength: 1000,label: false, input_html:{rows: 5, class: 'block w-full appearance-none rounded-md border border-gray-300 px-3 py-2 placeholder-gray-400 shadow-sm focus:border-emerald-900 focus:outline-none focus:ring-emerald-900 sm:text-sm'}, placeholder: "Write a comment...", required: true | ||
= f.hidden_field :post_id, value: post.id | ||
.flex.items-end.mt-3 | ||
= f.submit "Post", class: 'flex ml-auto justify-center btn-primary text-sm ' | ||
= f.submit "Post", class: 'flex ml-auto justify-center rounded-md border border-transparent bg-emerald-800 py-2 px-5 cursor-pointer text-sm font-medium text-white shadow-sm hover:bg-emerald-900 focus:outline-none focus:ring-2 focus:ring-emerald-500 focus:ring-offset-2' | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
ahoy.track
method is called unconditionally, which means it will track views even for the post's author. This could lead to inaccurate tracking data. Consider restoring the condition to exclude the post's author from tracking.