Using variables with if statement

Hi,

I have a list of attributes that are equal to either 0 or 1.

I am trying to "walk" through those attributes and if the attribute is equal to 1 it should do something.
Below is what I came up with but can't figure out the if statement comparison how it should be:

attributes/default.rb:
node.default['recipe']['testing'] = '1'
node.default['recipe']['something'] = '0'
node.default['recipe']['testing2'] = '0'

And the recipe that I came up with:

recipes/testing.rb:
%w{testing something testing2}.each do |check|
if node['recipe']["#{check}"] == 1
template "/path/to/something/#{check}.txt" do
source "#{check}.txt.erb"
owner 'root'
group 'root'
mode '0755'
end
end
end

I will not post the templates because they are not needed.

When I run the recipe I do not get any errors but the're no execution taking place, like the comprison never equals to 1 for any of the attributes.

Perhaps I am doing the above the wrong way? Is there any other method to achieve what I am trying to do?

Please help
THanks

1 != ‘1’ :slight_smile: --Noah

huh, you saved me after 2 days of headaches

Thanks!

Hi @coderanger,

Why you use this way ?..
1 != '1' is like 1 === 1 ?

Regards.

!= means not equal

Sorry, I was confused. I believe that the valor of attribute was a integer :sweat: