From fecbd27033938e871728982eb73f035015bfb5d2 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Thu, 15 May 2025 13:22:17 +0300 Subject: [PATCH] Rename @entry to @diary_entry to match model name --- app/controllers/diary_comments_controller.rb | 12 ++++++------ app/controllers/diary_entries_controller.rb | 18 +++++++++--------- app/views/diary_comments/new.html.erb | 4 ++-- app/views/diary_entries/show.html.erb | 20 ++++++++++---------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/app/controllers/diary_comments_controller.rb b/app/controllers/diary_comments_controller.rb index 5bbf2bf63..d5672c928 100644 --- a/app/controllers/diary_comments_controller.rb +++ b/app/controllers/diary_comments_controller.rb @@ -12,21 +12,21 @@ class DiaryCommentsController < ApplicationController allow_thirdparty_images :only => :create def create - @entry = DiaryEntry.find(params[:id]) - @comments = @entry.visible_comments - @diary_comment = @entry.comments.build(comment_params) + @diary_entry = DiaryEntry.find(params[:id]) + @comments = @diary_entry.visible_comments + @diary_comment = @diary_entry.comments.build(comment_params) @diary_comment.user = current_user if @diary_comment.save # Notify current subscribers of the new comment - @entry.subscribers.visible.each do |user| + @diary_entry.subscribers.visible.each do |user| UserMailer.diary_comment_notification(@diary_comment, user).deliver_later if current_user != user end # Add the commenter to the subscribers if necessary - @entry.subscriptions.create(:user => current_user) unless @entry.subscribers.exists?(current_user.id) + @diary_entry.subscriptions.create(:user => current_user) unless @diary_entry.subscribers.exists?(current_user.id) - redirect_to diary_entry_path(@entry.user, @entry, :anchor => "comment#{@diary_comment.id}") + redirect_to diary_entry_path(@diary_entry.user, @diary_entry, :anchor => "comment#{@diary_comment.id}") else render :action => "new" end diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index f3752cb2c..74149c68f 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -67,17 +67,17 @@ class DiaryEntriesController < ApplicationController def show entries = @user.diary_entries entries = entries.visible unless can? :unhide, DiaryEntry - @entry = entries.find_by(:id => params[:id]) - if @entry - @title = t ".title", :user => params[:display_name], :title => @entry.title + @diary_entry = entries.find_by(:id => params[:id]) + if @diary_entry + @title = t ".title", :user => params[:display_name], :title => @diary_entry.title @opengraph_properties = { - "og:title" => @entry.title, - "og:image" => @entry.body.image, - "og:image:alt" => @entry.body.image_alt, - "og:description" => @entry.body.description, - "article:published_time" => @entry.created_at.xmlschema + "og:title" => @diary_entry.title, + "og:image" => @diary_entry.body.image, + "og:image:alt" => @diary_entry.body.image_alt, + "og:description" => @diary_entry.body.description, + "article:published_time" => @diary_entry.created_at.xmlschema } - @comments = can?(:unhide, DiaryComment) ? @entry.comments : @entry.visible_comments + @comments = can?(:unhide, DiaryComment) ? @diary_entry.comments : @diary_entry.visible_comments else @title = t "diary_entries.no_such_entry.title", :id => params[:id] render :action => "no_such_entry", :status => :not_found diff --git a/app/views/diary_comments/new.html.erb b/app/views/diary_comments/new.html.erb index 91e646944..f52fca79c 100644 --- a/app/views/diary_comments/new.html.erb +++ b/app/views/diary_comments/new.html.erb @@ -2,11 +2,11 @@

<%= t ".heading" %>

<% end %> -<%= render :partial => "diary_entries/diary_entry_heading", :object => @entry, :as => "diary_entry" %> +<%= render :partial => "diary_entries/diary_entry_heading", :object => @diary_entry, :as => "diary_entry" %>

<%= t "diary_entries.show.leave_a_comment" %>

-<%= bootstrap_form_for @diary_comment, :url => comment_diary_entry_path(@entry.user, @entry) do |f| %> +<%= bootstrap_form_for @diary_comment, :url => comment_diary_entry_path(@diary_entry.user, @diary_entry) do |f| %> <%= f.richtext_field :body, :cols => 80, :rows => 20, :hide_label => true %> <%= f.primary %> <% end %> diff --git a/app/views/diary_entries/show.html.erb b/app/views/diary_entries/show.html.erb index c83189099..59dba0fe6 100644 --- a/app/views/diary_entries/show.html.erb +++ b/app/views/diary_entries/show.html.erb @@ -5,17 +5,17 @@ <% content_for :heading do %>
- <%= user_image @entry.user %> + <%= user_image @diary_entry.user %>
-

<%= link_to t(".user_title", :user => @entry.user.display_name), :action => :index %>

-

<%= rss_link_to :action => :rss, :display_name => @entry.user.display_name %>

+

<%= link_to t(".user_title", :user => @diary_entry.user.display_name), :action => :index %>

+

<%= rss_link_to :action => :rss, :display_name => @diary_entry.user.display_name %>

<% end %> -<%= render @entry, :truncated => false %> -<%= social_share_buttons(:title => @entry.title, :url => diary_entry_url(@entry.user, @entry)) %> +<%= render @diary_entry, :truncated => false %> +<%= social_share_buttons(:title => @diary_entry.title, :url => diary_entry_url(@diary_entry.user, @diary_entry)) %>
@@ -23,10 +23,10 @@ <% if current_user %>
- <% if @entry.subscribers.exists?(current_user.id) %> - <%= link_to t(".unsubscribe"), diary_entry_unsubscribe_path(@entry.user, @entry), :method => :post, :class => "btn btn-sm btn-primary" %> + <% if @diary_entry.subscribers.exists?(current_user.id) %> + <%= link_to t(".unsubscribe"), diary_entry_unsubscribe_path(@diary_entry.user, @diary_entry), :method => :post, :class => "btn btn-sm btn-primary" %> <% else %> - <%= link_to t(".subscribe"), diary_entry_subscribe_path(@entry.user, @entry), :method => :post, :class => "btn btn-sm btn-primary" %> + <%= link_to t(".subscribe"), diary_entry_subscribe_path(@diary_entry.user, @diary_entry), :method => :post, :class => "btn btn-sm btn-primary" %> <% end %>
<% end %> @@ -39,7 +39,7 @@ <% if current_user %>

<%= t ".leave_a_comment" %>

- <%= bootstrap_form_for @entry.comments.new, :url => comment_diary_entry_path(@entry.user, @entry) do |f| %> + <%= bootstrap_form_for @diary_entry.comments.new, :url => comment_diary_entry_path(@diary_entry.user, @diary_entry) do |f| %> <%= f.richtext_field :body, :cols => 80, :rows => 20, :hide_label => true %> <%= f.primary %> <% end %> @@ -49,5 +49,5 @@
<% content_for :auto_discovery_link_tag do -%> -<%= auto_discovery_link_tag :rss, :action => :rss, :display_name => @entry.user.display_name %> +<%= auto_discovery_link_tag :rss, :action => :rss, :display_name => @diary_entry.user.display_name %> <% end -%> -- 2.39.5