Home > Mobile >  Rubocop warning SymbolProc in blueprinter serializer custom field in Rails
Rubocop warning SymbolProc in blueprinter serializer custom field in Rails

Time:09-16

I have a Blueprinter serializer with a custom field (see screenshot)

enter image description here

field :score_details do |user|
  user.score_details
end

and you can see a Rubocop warning for this block and I can't make it disappear. I read the Rubocop doc : SymbolProc but without success..

To explain in details: I have a User model in which I include a concern in order to calculate a score. In this concern I have 1 method (with no parameter) which returns a simple integer. Finally, I use this method in my UserSerializer in order to render my score to my frontend.

Here is my include in my User model:

class User < ApplicationRecord
  include UserScoresConcern
end

Here is my concern:

module UserScoresConcern
  extend ActiveSupport::Concern

  included do
    def score_details
      # this method return 45 for example
      calculate_user_score_details
    end
  end
end

What can I do to fix this warning? Has anyone ever encountered the same issue?

Thanks

  • Related