Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action Text: Add method to confirm rich text content existence by adding ? after content name #37951

Merged

Conversation

t0yohei
Copy link
Contributor

@t0yohei t0yohei commented Dec 13, 2019

Summary

This is the pull request based on #37594

This change introduces a rich text object to make
it easier to confirm it context is existing or not.

Other Information

If we have a class like below.

class Information < ApplicationRecord
  has_rich_text :notes
end

Before:

i = Information.new
i.notes? => NoMethodError
i.notes = "Some sample text"
i.notes.present? => true

After:

i = Information.new
i.notes? => false

i.notes = "Some sample text"
i.notes? => true

@rails-bot rails-bot bot added the actiontext label Dec 13, 2019
…ontent name

This change introduces a rich text object to make
it easier to confirm it context is existing or not.

If we have a class like below.

class Information < ApplicationRecord
  has_rich_text :notes
end

Before:
i = Information.new
i.notes? => NoMethodError
i.notes = "Some sample text"
i.notes.present? => true

After:
i = Information.new
i.notes? => false

i.notes = "Some sample text"
i.notes? => true
@t0yohei t0yohei force-pushed the add-missing-action-to-action-text branch from 5c18fe6 to 07533a3 Compare December 13, 2019 03:59
@rails-bot
Copy link

rails-bot bot commented Mar 12, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@rails-bot rails-bot bot added the stale label Mar 12, 2020
@rails-bot rails-bot bot closed this Mar 19, 2020
@rafaelfranca rafaelfranca reopened this Mar 19, 2020
@rails-bot rails-bot bot removed the stale label Mar 19, 2020
@rafaelfranca rafaelfranca merged commit 1add738 into rails:master Mar 19, 2020
@t0yohei t0yohei deleted the add-missing-action-to-action-text branch March 21, 2020 15:39
abhaynikam added a commit to abhaynikam/rails that referenced this pull request Jun 3, 2021
Similar to: rails#37951

Example:
```
class User < ActiveRecord::Base
  has_one_attached :avatar
  has_many_attached :documents
end
```

Before:
```
user = User.create!
user.avatar.attached?    # => false
user.documents.attached? # => true
```

After:
```
user.avatar?    # => false
user.documents? # => true
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants