Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 罗。在rails中设置助手方法的样式_Ruby On Rails - Fatal编程技术网

Ruby on rails 罗。在rails中设置助手方法的样式

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

我正在尝试设计一个助手方法。该方法工作得很好,但html_-safe(或者我在这里是如何做到的)无法对其进行样式化。我尝试了其他的变体,比如将html_安全地放在后面

这是我的最新方法

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_安全
结束