I’m using RESTful Rails, and I’m not sure how to filter out the XML
sheet by title.
I thought you could simply type in something like this:
/people.xml?title=CEO, but it’s not filtering for me.
What would I have to do to be able to filter out the results correctly?
Bob,
I haven’t actually used XML with Rails, but by my understanding,
calling:
/people.xml?title=CEO
is technically no different than calling:
/people?title=CEO
It just gives you the option to handle it via XML because of the
respond_to. You still have to process the parameters, i.e. in the
PeoplesController class for the “index” action, you might simply have:
def index
@people = Person.find_all_by_title(params[:title])
respond_to do |format|
format.html
format.xml { render :xml => @people }
end
end
You could probably get fancy with some metaprogramming but that might
be more than necessary.
HTH!
-Danimal
On Mar 29, 4:54 pm, Bob S. [email protected]
Danimal, you made it a million times more clearer. Thank you so much for
the great explanation. I really appreciate it!