1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actiontext/lib/action_text
Jonathan Hefner 8cc8fe9628 Don't render layout in ActionText::Content#inspect
Prior to this commit, `ActionText::Content#inspect` called `#to_s` and
truncated the result to 25 characters.  However, `#to_s` calls
`#to_rendered_html_with_layout` which, by default, renders the same
first 25 characters for every instance.

For example, with models such as:

```ruby
class Message < ActiveRecord::Base
  has_rich_text :content
end

Message.create(content: "first message")
Message.create(content: "second message")
Message.create(content: "third message")
```

The output of `#inspect` is indistinguishable:

```irb
irb> Message.all.map { |message| message.content.body }
  Rendered .../actiontext/app/views/action_text/contents/_content.html.erb within layouts/action_text/contents/_content (Duration: 2.4ms | Allocations: 881)
  Rendered .../actiontext/app/views/action_text/contents/_content.html.erb within layouts/action_text/contents/_content (Duration: 0.7ms | Allocations: 257)
  Rendered .../actiontext/app/views/action_text/contents/_content.html.erb within layouts/action_text/contents/_content (Duration: 0.6ms | Allocations: 257)
=> [#<ActionText::Content "<div class=\"trix-conte...">,
    #<ActionText::Content "<div class=\"trix-conte...">,
    #<ActionText::Content "<div class=\"trix-conte...">]
```

This commit changes `#inspect` to call `#to_html`, which does not render
the Action Text layout.  So the output of `#inspect` will be:

```irb
irb> Message.all.map { |message| message.content.body }
=> [#<ActionText::Content "first message">,
    #<ActionText::Content "second message">,
    #<ActionText::Content "third message">]
```
2022-02-01 11:58:12 -06:00
..
attachables
attachments Always use OpenSSL constants for Digest operations 2021-06-30 13:57:54 +02:00
attachable.rb Improve ActionText extensiblibility 2020-12-29 20:06:45 -05:00
attachment.rb Replace map + compact with filter_map 2021-04-22 22:08:34 -03:00
attachment_gallery.rb Fixes failing ActionText::ContentTest test cases 2021-03-30 16:38:11 -04:00
attribute.rb Fixes Options documention formatting for has_rich_text 2022-01-22 13:57:47 -06:00
content.rb Don't render layout in ActionText::Content#inspect 2022-02-01 11:58:12 -06:00
encryption.rb Enable Performance/MapCompact cop 2021-04-23 16:33:02 +09:00
engine.rb No underscore style (#42898) 2021-07-28 15:34:59 -04:00
fixture_set.rb DOCS: Improve ActionText FixtureSet Ruby docs 2021-10-12 09:45:06 -04:00
fragment.rb
gem_version.rb Start Rails 7.1 development 2021-12-07 15:52:30 +00:00
html_conversion.rb
plain_text_conversion.rb Better ActionText plain text output for nested lists (#37976) 2021-10-12 18:05:04 +02:00
rendering.rb Standardize nodoc comments 2021-07-29 21:18:07 +00:00
serialization.rb Fix ActionText::Serialization when dumping an ActionText::RichText 2021-09-20 10:36:20 +02:00
system_test_helper.rb
trix_attachment.rb Eliminate some Integer() rescue nil patterns in Action Text 2021-08-26 19:39:44 +02:00
version.rb