rails-settings icon indicating copy to clipboard operation
rails-settings copied to clipboard

Default settings with a nested hash

Open FabianPv opened this issue 7 years ago • 1 comments

example: default settings with this hash has_settings do |s| s.key :conecction, :defaults => { :user => '', :password => '' } end

it's working perfectly, but if I use a nested hash like this one:

has_settings do |s| s.key :conecction, :defaults => { :user => '', :password => '', :credentials => { :token: "", :mail:"" } } end

once the values are assigned, the database it's only stores the user and the password..

FabianPv avatar Oct 24 '18 22:10 FabianPv

Yep I'm not sure deeply nested defaults are supported. You might need to workaround your problem and consider

has_settings do |s|
  s.key :conecction, :defaults => {
    :user => '',
    :password => '',
    :credentials_token => '',
    :credentials_mail => ''
  }
end

... although you potentially also want to reconsider the format in which you're storing passwords, if you're storing them in plain text.

olliebennett avatar Nov 14 '18 15:11 olliebennett