だから私はこのアプリケーションで見つかったマイクロポストに返信を追加しようとしていますhttps://github.com/railstutorial/sample_app_2nd_ed
モデルとコントローラーのすべてを理解したと思いますが、それは重要なことではありません。
app/views/microposts/_micropost.html.erb に返信リンクを追加しようとすると。それは決して機能しません。
<li>
<span class="content"><%= micropost.content %></span>
<p>this text doesnt show up!</p>
<span class="timestamp">
Posted <%= time_ago_in_words(micropost.created_at) %> ago.
</span>
<% if current_user?(micropost.user) %>
<%= link_to "delete", micropost, method: :delete,
confirm: "You sure?",
title: micropost.content %>
<% end %>
<%= link_to "reply", new_comment_path(:micropost_id => comment) %> |
<p> why isnt this working!!?</p>
</li>
ご覧のとおり、3 行目、13 行目、15 行目に基本的なテキストまたは返信リンクを追加しようとしました。それは決して現れません。私はこれを間違っていますか?返信リンクや表示したい基本的なテキストはどのような形式で入力すればよいですか?
これが私のマイクロポストコントローラーコードです
class MicropostsController < ApplicationController
before_filter :signed_in_user
before_filter :correct_user, only: :destroy
def create
@micropost = current_user.microposts.build(params[:micropost])
if @micropost.save
flash[:success] = "Micropost created!"
redirect_to root_path
else
@feed_items = []
render 'static_pages/home'
end
end
def destroy
@micropost.destroy
redirect_back_or root_path
end
private
def correct_user
@micropost = current_user.microposts.find_by_id(params[:id])
redirect_to root_path if @micropost.nil?
end
end
ここに私のコメントコントローラーがあります
class CommentsController < ApplicationController
def create
@comment = @micropost.comments.new(params[:comment])
if @comment.save
redirect_to @user
else
redirect_to @user
end
end
def destroy
@comment.destroy
redirect_back_or root_path
end
end