-1
我正在使用表单发布到博客。在博客展示帖子页面上,我使用rails内容显示标签上的==来解释html。如何隐藏HTML标签?
但是,我有一个博客索引页面,显示最新的帖子,我想截断的帖子预览不解释html,但同时隐藏html标签。
我该怎么做?
def blog
#@content3 = Content.find(3)
@blogPosts = Blogpost.all.reverse.drop(1)
@latestPost = Blogpost.last
if @latestPost.blank? == false
@blogPicture = Blogpost.last.image
end
respond_to do |format|
format.html { render :layout => 'blog' }
end
end
请让我们看看你的代码。 – Severin 2014-10-17 20:15:13
<%= truncate(@ latestPost.content,:length => 200,:separator =>'')%> – Callum 2014-10-17 20:18:56
添加控制器代码到主线程: – Callum 2014-10-17 20:19:16