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

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

Open
acorcutt opened this issue Feb 7, 2010 · 0 comments
Open

Comments

@acorcutt
Copy link

acorcutt commented Feb 7, 2010

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?

ryanlchan referenced this issue in ryanlchan/bitmask_attributes Apr 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant