IF Statements in Ruby [closed]
Assuming I have have a text box and a button on a page written in Rails what would be the code to compare a string inputted in that box with another string (non-dynamic开发者_开发知识库)?
Does Rails have the same structure as Java when testing If statements like:
IF text1 = text2 Then
... do something ...
Else
... do something ...
Thanks, Nick
if text1 == text2
...
elsif text2 == text3
...
else
...
end
http://en.wikibooks.org/wiki/Ruby_Programming/Syntax/Control_Structures#if_expression
http://www.ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#if
In controller
if params[:text_box_name_1].to_s == params[:text_box_name_2].to_s
----
else
end
I think this might help: http://www.howtogeek.com/howto/programming/ruby/ruby-if-else-if-command-syntax/
精彩评论