Ruby - Nested IF statement syntax -
I'm trying to get this nested if the statement works but my syntax is incorrect and I can not understand it . I have a search box and a type of drop-down on the train 4 app. On the search results page, I want to sort product entries that the user chooses in the order dropdown. If a user does not enter the search term, I have to display a message. Here is my controller code.
If I remove the conditions and display only a default sort, then the search results page is displayed so that the error statement is in syntax.
def search if the search [: search]. Display? If Parameters [: Sort] == "- Price - Low" Highlighting "=" Eligible Parameters [: Sort] == "- High - High" High to Low "@listings = ... Elsf Param [[Sort] == "- New recurring" @ listing = ... Elsf params [: Sort] == "- random drag" @ listing = ... and @ listing = ... end and flash [: notice] = "Please enter one or more search terms such as blue shirt "End"
What you want here is a case Javascript and C: def search or other search from other languages switch from the other languages. [Search:]. Display? "List - = High to Low "... when" - value - high to high "... when" - new recurring "... when" - random shuffle "... and ... end and flash [: notice] =" please Enter one or more search terms like blue shirts. "In Ruby, see the case The result can be used to specify a variable, so that lots of @listings are eliminated = the recurrence goes for the same if . < / P> What you're comparing is extraordinarily typical here, if you have a drop-down list that is being used to select a sort order, then they have more intrinsically accurate Value should be, such as plh "value - free To represent "high from the point", or even numeric code. This means that if your code changes, then your code still works.
Comments
Post a Comment