@host variable does not work in if-statement

On a provisioning template the following does not work:

<% if @host.architecture == 'x86_64' -%>
foo
<% end -%>

Where the following prints: x86_64

<%= @host.architecture %>

What am I doing wrong here ?

Use: if @host.architecture.to_s == 'x86_64'

··· On 25/04/17 22:05, Matt . wrote: > On a provisioning template the following does not work: > > <% if @host.architecture == 'x86_64' -%> > foo > <% end -%>


Dominic Cleal
dominic@cleal.org

Yes I found that finally and also .name is possible instead of .to_s.

Why is this ?

··· Op woensdag 26 april 2017 09:08:17 UTC+2 schreef Dominic Cleal: > > On 25/04/17 22:05, Matt . wrote: > > On a provisioning template the following does not work: > > > > <% if @host.architecture == 'x86_64' -%> > > foo > > <% end -%> > > Use: if @host.architecture.to_s == 'x86_64' > > -- > Dominic Cleal > dom...@cleal.org >

@host.architecture is an object (a model) which is not directly equal to
a string ("x86_64"). .name or .to_s return the string containing the
name of the architecture.

··· On 26/04/17 11:00, Matt wrote: > Yes I found that finally and also .name is possible instead of .to_s. > > Why is this ?


Dominic Cleal
dominic@cleal.org