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

do not alias rich text area if it is not defined #709

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Metrics/AbcSize:

Metrics/BlockLength:
Exclude:
- "lib/bootstrap_form/inputs/base.rb"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can leave this one in here, since it applies to the whole file anyway. But I should look at the rule and where it came from. I'm a fan of RuboCop, but not of these rules that put arbitrary limits on the size of things.

- "demo/config/**/*"
- "demo/test/**/*"
- "test/**/*"
Expand Down
7 changes: 7 additions & 0 deletions lib/bootstrap_form/inputs/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ def bootstrap_select_group(field_name)
bootstrap_alias field_name
end

# Creates the methods *_without_bootstrap and *_with_bootstrap.
#
# If your application did not include the rails gem for one of the dsl
# methods, then a name error is raised and suppressed. This can happen
# if your application does not include the actiontext dependency due to
# `rich_text_area` not being defined.
def bootstrap_alias(field_name)
alias_method "#{field_name}_without_bootstrap".to_sym, field_name
alias_method field_name, "#{field_name}_with_bootstrap".to_sym
rescue NameError # rubocop:disable Lint/SuppressedException
end
end

Expand Down
Loading