I know this is probably rather trivial but I have had a look at previous questions and I’ve tried them but they still issued an error unfortunately :s
My issue is the following, I have an html.erb file and I want a certain body text to be display given a condition or another if it is false
I have
<% if !@selector.nil do %>
more code goes here
<% end %>
I have tried many combinations but the most frequent error i keep getting is
You have a nil object when you didn't expect it!
The error occurred while evaluating nil.nil
I’m not sure what I’m doing wrong, this is most likely something very easy but I can’t find my way through it!
There’s no
.nilmethod. You’re thinking of.nil?. It should be!@selector.nil?.Or you could get the same result from
if @selectorand it will evaluate to be the same asif !@selector.nil?. This is assuming you not referring to a boolean.