Hello, i have started using ruby on rails, and searched the web for
this information but found nothing!
My problem is : i have main.html.rb and inside a conditional :
<% if controller.controller_name == “main” %>
do something
<% else if controller.controller_name == “other_controller” %>
do something
<% else %>
do something
<% end %>
The problem is: im using netbeans and netbeans shows “Unexpected-end-
of-file” at the end in the close html tag.
So whats the problem? There is not else if tags in ror? If i use if -
else - end it runs fine but not if-else if-else-end.TIA
Hi, thanks for the reply, the problem is : when i use elseif and run
the program, i get an error saying that it cannot recognize elseif and
strangely all ruby code in netbeans color syntax is in blue but not
elseif statements?. This is what i get when running elseif :
All of the following are valid.
The third one is retarded, because by not putting the second if on a
new line, you don’t get the indentation, so you can’t visually tell if
you’ve got the right number of clauses. I prefer the fourth way.
Notice that the 3rd and 4th methods have an extra end, whereas the
second method has only one end.
if(true)
puts ‘yay’
else
puts ‘nay’
end
if(false)
puts ‘yay’
elsif(true)
puts ‘nay’
end
if(false)
puts ‘woo’
else if(true)
puts ‘boo’
end
end
if(false)
puts ‘woo’
else
if(true)
puts ‘boo’
end
end