We've moved discussions to Discord

I think I found a bug in team_member.rb

Alain Pilon
In models/team_member.rb we have this:

  # Cast roles to/from booleans
  ROLES.each do |role|
    define_method(:"#{role}=") { |value| super ActiveRecord::Type::Boolean.new.deserialize(value) }
    define_method(:"#{role}")  { ActiveRecord::Type::Boolean.new.deserialize super() }
    define_method(:"#{role}?") { role == true }
  end

How can role? ever return something other than false?  Unless you have a role named true ;-)

Shouldnt it be something like ?
define_method(:"#{role}?") { self.roles.fetch(role.to_s, false) }


Chris Oliver
Good find! That is absolutely a bug. It should actually be "send(role)" since in that block, role is a symbol of the role name and we actually need to ask the store for the value rather than match the symbol against "true".
Notifications
You’re not receiving notifications from this thread.