Table plus search type

17 views
Skip to first unread message

tomkins

unread,
Sep 4, 2012, 7:51:28 AM9/4/12
to hobo...@googlegroups.com
I have noticed that the table plus search box always takes the value as a string, is there any way to search by the same type as the column in SQL, eg date?
Thanks.

Vivek Sampara

unread,
Sep 4, 2012, 7:54:49 AM9/4/12
to hobo...@googlegroups.com
I think you should add a custom search control and you can ask the controller to catch the param for the column and process it in the model . 

Vivek 

On Tue, Sep 4, 2012 at 5:21 PM, tomkins <j.to...@live.com> wrote:
I have noticed that the table plus search box always takes the value as a string, is there any way to search by the same type as the column in SQL, eg date?
Thanks.

--
You received this message because you are subscribed to the Google Groups "Hobo Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/hobousers/-/cYjiyCHy7jQJ.
To post to this group, send email to hobo...@googlegroups.com.
To unsubscribe from this group, send email to hobousers+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.

Bryan Larsen

unread,
Sep 4, 2012, 9:50:19 AM9/4/12
to hobo...@googlegroups.com
You're entirely responsible for the search. All table-plus does is
provide it in params[:search] to your controller method. The
examples generally pass params[:search] to the search automatic scope,
but you don't have to do that.

For example, you could do:

begin
self.this = Foo.find_by_date_published(Date.parse(params[:search]))
rescue ArgumentError => e
self.this = Foo.search(params[:search], title)
end
self.this = self.this.paginate(:page => params[:page)

Bryan
Reply all
Reply to author
Forward
0 new messages