class RuboCop::Cop::Rails::ArelStar
This cop prevents usage of `“*”` on an Arel::Table column reference.
Using `arel_table` causes the outputted string to be a literal quoted asterisk (e.g. `my_model`.`*`
). This causes the database to look for a column named `*`
(or `“*”`) as opposed to expanding the column list as one would likely expect.
@example
# bad MyTable.arel_table["*"] # good MyTable.arel_table[Arel.star]
Constants
- MSG
- RESTRICT_ON_SEND
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/rails/arel_star.rb, line 31 def on_send(node) return unless (star = star_bracket?(node)) add_offense(star) do |corrector| corrector.replace(star.loc.expression, 'Arel.star') end end