Skip to content

String lists not getting converted to symbols until after db load #3

@acorcutt

Description

@acorcutt

Hi, I've found a small problem when setting the bitmask to a list of strings (for example the output from checkbox parameters) and checking the state before a db save.

I can see in ValueProxy value.to_sym is used to convert things back to symbols after its pulled from the db, but if you want to check the status before the db save it looks like its using the original (string) list.

bitmask :disabled, :as => [:delete,:hide]

@user = current_user

puts @user.disabled = [:delete,:hide]
puts @user.disabled?(:hide) #true
puts @user.disabled?(:delete) #true
puts @user.disabled = ["delete","hide"] #eg from checkboxes
puts @user.disabled?(:hide) #false when tested agains symbol
puts @user.disabled?("delete") #true

I'm converting the list to symbols before I set it, but could this be done in the setter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions