Q: RJS error: TypeError: element.style is undefined in rails
Ans : add prototype js in your html page.
arr = [1,2,3,4] str = '' i = 0 arr.each do |a| if i % 3 == 0 str<<"#{a}" else str<<"#{a}" end i = i+1 if i % 3 == 0 || arr.length == i str <<" " end end puts str.inspect output is like :
1
2
3
4
strip_tags("Strip these tags!") # => Strip these tags! strip_tags("Bold no more! See more here...") # => Bold no more! See more here... strip_tags("Welcome to my website!") # => Welcome to my website!
strip_links('Ruby on Rails') # => Ruby on Rails strip_links('Please e-mail me at me@email.com.') # => Please e-mail me at me@email.com. strip_links('Blog: Visit.') # => Blog: Visit
<%= sanitize @article.body %>You can add or remove tags/attributes if you want to customize it a bit. See ActionView::Base for full docs on the available options. You can add tags/attributes for single uses of sanitize by passing either the :attributes or :tags options:
<%= sanitize @article.body %>Custom Use (only the mentioned tags and attributes are allowed, nothing else)
<%= sanitize @article.body, :tags => %w(table tr td), :attributes => %w(id class style)Add table tags to the default allowed tags
Rails::Initializer.run do |config| config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td' endRemove tags to the default allowed tags
Rails::Initializer.run do |config| config.after_initialize do ActionView::Base.sanitized_allowed_tags.delete 'div' end endChange allowed default attributes
Rails::Initializer.run do |config| config.action_view.sanitized_allowed_attributes = 'id', 'class', 'style' endPlease note that sanitizing user-provided text does not guarantee that the resulting markup is valid (conforming to a document type) or even well-formed. The output may still contain e.g. unescaped ’<’, ’>’, ’&’ characters and confuse browsers.