Ruby on rails Ruby on Rails呈现html语法被“取消”;

Ruby on rails Ruby on Rails呈现html语法被“取消”;,ruby-on-rails,Ruby On Rails,我想在Ruby On Rails中使用html代码将单词“Hello”变成蓝色,但是我的语法出现了错误,因为“.”取消了我的呈现html。在呈现html函数中是否有其他方法可以使用“?谢谢 class ApplicationController < ActionController::Base protect_from_forgery with: :exception def hello render html: "<h1 style="color:blue;">

我想在Ruby On Rails中使用html代码将单词“Hello”变成蓝色,但是我的语法出现了错误,因为“.”取消了我的呈现html。在呈现html函数中是否有其他方法可以使用“?谢谢

class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  def hello
    render html: "<h1 style="color:blue;">Hello</h1>"
  end
end
class ApplicationController
在本例中,您有两个分开的字符串
“Hello”

可以在样式周围加单引号,而不是双引号

def hello
    render html: "<h1 style='color:blue'>Hello</h1>".html_safe
end
def你好
呈现html:“你好”。html\u安全
结束
并在html字符串的末尾添加

将字符串标记为受信任的安全字符串


在本例中,您有两个分开的字符串
“Hello”

可以在样式周围加单引号,而不是双引号

def hello
    render html: "<h1 style='color:blue'>Hello</h1>".html_safe
end
def你好
呈现html:“你好”。html\u安全
结束
并在html字符串的末尾添加

将字符串标记为受信任的安全字符串


谢谢,就是这样,现在可以用了谢谢,就是这样,现在可以用了