arrays - Ruby How to display message if include? statement is true or false -


i'm very new ruby , attempting display 1 of 2 messages based on whether words included in array. current controller contains following:

@cookie = ["gluten", "sugar", "dairy", "chocolate"] 

and view contains this:

<%= @cookie.include?"gluten" %> 

the above returns 'true' , prints on page fine. however, nothing gets printed on page when trying either of following methods. page renders fine no errors, no messages:

<%= puts "sorry" if @cookie.include?"gluten" %> 

and

<%=  if @cookie.include?("gluten")   puts "sorry, cannot eat this."     else   puts "you have greenlight."     end %> 

i'm hoping i'm creating simple mistake in syntax or misunderstanding usage of include? function.

looking @ ruby appears sound, http://rubyfiddle.com/riddles/d6798.

must rails error try

<% if @cookie.include?("gluten") %>   <%= "sorry, cannot eat this." %> <%  else %>   <%= "you have greenlight." %> <%  end %> 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -