Ruby on rails 罗。在rails中设置助手方法的样式
我正在尝试设计一个助手方法。该方法工作得很好,但html_-safe(或者我在这里是如何做到的)无法对其进行样式化。我尝试了其他的变体,比如将html_安全地放在后面 这是我的最新方法Ruby on rails 罗。在rails中设置助手方法的样式,ruby-on-rails,Ruby On Rails,我正在尝试设计一个助手方法。该方法工作得很好,但html_-safe(或者我在这里是如何做到的)无法对其进行样式化。我尝试了其他的变体,比如将html_安全地放在后面 这是我的最新方法 def tweeted_text(counted) if current_user.tweets.count == 1 first = "<b>current_user.tweets.count.to_s</b>" + " Tweet
def tweeted_text(counted)
if current_user.tweets.count == 1
first = "<b>current_user.tweets.count.to_s</b>" + " Tweet"
first.html_safe
else
second = "<b>current_user.tweets.count.to_s</b>" + " Tweets"
second.html_safe
end
end
def tweeted_文本(计数)
如果当前_user.tweets.count==1
first=“current_user.tweets.count.to_s”+“Tweet”
first.html_安全
其他的
second=“current_user.tweets.count.to_s”+“tweets”
second.html_安全
结束
结束
在我看来
<%= tweeted_text(@counted) %>
设置我的助手的样式的合适方法是什么?
ty请试试这个
def tweet_文本
结果=“#{current_user.tweets.count}Tweet”
结果=如果当前_user.tweets.count>1,则结果+s
result.html_安全
结束