Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.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 3 为自动生成html创建筛选器_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 3 为自动生成html创建筛选器

Ruby on rails 3 为自动生成html创建筛选器,ruby-on-rails-3,Ruby On Rails 3,我想为auto_html创建一个自定义过滤器。我应该把过滤器放在哪里以便使用? 文档中没有涉及到这些内容。谢谢 我采取的方法是将代码添加到初始值设定项文件中,例如: /path/to/your/application/config/initializers/auto_html.rb 然后你可以写一些东西,比如: AutoHtml.add_filter(:change_colours).with({}) do |text, options| text.gsub("#FF0000", "#00F

我想为auto_html创建一个自定义过滤器。我应该把过滤器放在哪里以便使用?
文档中没有涉及到这些内容。谢谢

我采取的方法是将代码添加到初始值设定项文件中,例如:

/path/to/your/application/config/initializers/auto_html.rb

然后你可以写一些东西,比如:

AutoHtml.add_filter(:change_colours).with({}) do |text, options|
  text.gsub("#FF0000", "#00FF00")
end 
并在模型中调用
auto\uhtml(input){change\u colors}
。空哈希将接受您希望传递给筛选器的任何选项