I'm doing something like this now. I first started with the url representation of a search instead of form contents. Then moved on to be able to take a form and create a url from its data.
This approach has two benefits for me: 1 - I start knowing that everything is "searchable" through an http/ rest-like query interface. 2 - My merb server doesn't known anything about the form. It has a param filter and simple custom code to guard the inputs. For example: http://mysite.com/books?filter=all;page=2; This url/query param format may not be rails-ish sexy but it works and allow me to guard against the filter and page variables so they are only within "searches" that my app currently allows. You can have whatever variables you want and the server only pays attention to the ones the server guards against and ignores the rest. ~ Jon On Nov 30, 6:48 pm, Worrab <[email protected]> wrote: > This is probably really straightforward, but I haven't been able to > work out how to build a search into a Merb form and secondly how to > build a form to enter criteria for a SQL search. > > For instance, if I have a list of authors, how would a have a field on > the form that users could enter "Br%" with a 'search' button and get > the parameter back to the index ( eg: @authors = Author.all > (:surname.like => 'Br%') > > Secondly - and for all I know it's related (!) - if I wanted to list > books and authors, I might have a general search form that had fields > the user could fill in, and build a query with non-blank values. Then > I could use the query as the basis for another form to display the > details. > > Any pointers would be greatly valued - thanks. -- You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/merb?hl=en.
