I’ve been experimenting with Rails over the past couple of days and
have come across something that seems harder than it should be. In
previous frameworks I have used (WebObjects, php) a full search page
(which leads into a list view populated with search results) was part
of the CRUD that was either dynamically or statically created after
specifying table/object schema. In WebObjects this was a very cool
feature of DTW (direct to web), in php I rolled my own crud generator
with searching capabilities even though I’m sure plenty exist already.
I’ve looked through the archives and google and have found mentions
of the lack of a search page in Rails, but as yet no solutions. I’m
wondering if there are any plugins or scaffolding enhancements that
add a search page to the basic CRUD interface. I’m not looking for a
full text search just an interface that provides a form containing
all table fields that, once submitted, builds a database query and
returns the results.
TIA,
Dan
I’m also looking for a search scaffold plugin… anybody?
Shimon A. wrote:
I’m also looking for a search scaffold plugin… anybody?
…and I was thinking of exactly this a while back… and was going to
post to the list asking about it at night… 
Thanks for asking for me…
Cheers
Mohit.
The “Rails Recipes” book has something that could help… a generic
model
search…from there to a plugin it should be a short way…
2006/8/7, Mohit S. [email protected]:
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Michael S. [email protected]
www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
Mohit S. wrote:
Thanks Michael,
Actually, that was the reason I had scheduled to ask at night… cos I
planned to take a look at the Recipes book before posting my question…
I think AWDWR2 does not really go into this aspect in much detail…
Cheers
Mohit.
this may be completely off, but here is an article on creating a live
search with sortable table columns and pagination:
http://dev.nozav.org/rails_ajax_table.html
i’ve used it in a few smaller projects and the search part might be of
some use.
Thanks Michael,
Actually, that was the reason I had scheduled to ask at night… cos I
planned to take a look at the Recipes book before posting my question…
I think AWDWR2 does not really go into this aspect in much detail…
Cheers
Mohit.
heri rakotomalala wrote:
well, for me, this takes two lines of code
def search
@items_pages, @items = paginate ‘Item’, :conditions => [‘name LIKE ?’,
params[:search_text]], :per_page => 10
render :action => :list
end
Isn’t that vulnerable to SQL Injection attacks?
well, for me, this takes two lines of code
def search
@items_pages, @items = paginate ‘Item’, :conditions => [‘name LIKE ?’,
params[:search_text]], :per_page => 10
render :action => :list
end
so you reuse the list view
Heri
http://sprinj.com
Nope – the placeholder will be safely replaced by whatever string there
is
in params[:search_text]