0
所以我試圖添加回覆在這個應用程序中發現的微博https://github.com/railstutorial/sample_app_2nd_ed爲什麼不在我的ruby on rails應用程序中顯示我的html?
我想我找出了所有的模型和控制器的東西,但除此之外。
當我嘗試向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
您是否有機會渲染局部變量? – DVG
我明白部分是什麼,但它應該呈現在哪裏?哪一個應該是?謝謝! – BigBoy1337