Could anyone give any examples of how to use FOR and IF loops in a rails controller?
Here is some 'pseudo code' (using the term very loosely) which will hopefully illustrate what I want to do -
For the sake of this example, I am using a table called 'chairs' and I want to query the 'age' column to show all chairs that are (eg) 2 years old. [:id] is a numeric variable that I'm passing into it. in my working project I have already set up the routes and am able to render basic :all xml to the URL, but I need it to display specific records, as follows...
For each chair in chairs
if chair.age = [:id]
render records to xml
end
end
Would appreciate any help.
Edit - i understand how FOR and IF loops work, just need some examples of how to achieve the above in the rails controller.