Forum: Ruby on Rails Prompting user to enter value to feed Find

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Gene K. (Guest)
on 2006-05-29 09:37
Hi,
While viewing part of a long list of records, the user may want to do a
Find of a specific record (for example, find_by_name). The found record
is then displayed using the list view. I've searched the wiki and
couldn't find a sample or information that will help directly in
implementing this function. Any pointers?
Thanks!
gk
Matthew Wastrodowski (Guest)
on 2006-05-29 11:13
(Received via mailing list)
Gene K. wrote:
> Hi,
> While viewing part of a long list of records, the user may want to do a
> Find of a specific record (for example, find_by_name). The found record
> is then displayed using the list view. I've searched the wiki and
> couldn't find a sample or information that will help directly in
> implementing this function. Any pointers?
> Thanks!
> gk
>
>
 Could you pass the name through the query string, and if that string is
present just overwrite the value
in the list @ variable with a find(:all, :conditions => ["name =
?",params[:name]])?

--
Matthew Wastrodowski
Web D.
http://blog.familopia.com

removed_email_address@domain.invalid
949 395-7215
Charlie B. (Guest)
on 2006-05-29 16:41
Hi,
While viewing part of a long list of records, the user may want to do a
Find of a specific record (for example, find_by_name). The found record
is then displayed using the list view. I've searched the wiki and
couldn't find a sample or information that will help directly in
implementing this function. Any pointers?
Thanks!
gk

I have a pretty good tutorial for this right here.

http://www.recentrambles.com/pragmatic/view/59

Charlie B.
http://www.recentrambles.com
Gene K. (Guest)
on 2006-05-29 18:34
charlie bowman wrote:
> Hi,
> While viewing part of a long list of records, the user may want to do a
> Find of a specific record (for example, find_by_name). The found record
> is then displayed using the list view. I've searched the wiki and
> couldn't find a sample or information that will help directly in
> implementing this function. Any pointers?
> Thanks!
> gk
>
> I have a pretty good tutorial for this right here.
>
> http://www.recentrambles.com/pragmatic/view/59
>
> Charlie B.
> http://www.recentrambles.com

Awesome! Live search is what I'd like to use eventually, but for now I'm
still taking baby steps. The site looks elegant.

thanks
gk
Gene K. (Guest)
on 2006-05-29 19:08
Matthew Wastrodowski wrote:
Hi,
At this point the grid display is populated from a variable that is set
in the controller as follows, and hence, there is no explicit query
string.

  def list
    @items = Item.find_all
  end

What I'm doing, a really simplistic thing, is, at the bottom of the grid
display for a model, I add a FIND link as follows:

<%= link_to "FIND item",
:controller => "item",
:action => "list" %>

When the user clicks on the link, a prompt window should appear and
allow the user to enter a value. It seems that I'd need a view to
display the prompt window, collect the search value, and then call the
list method of the relevant controller and pass the search value. So,
I'd have to change this list method to something like:

  def list
    if @flag
      @items = Item.find_all
    else
      @items = Item.find_by_name("aValue")
    end
  end

Somewhere I need to redirect the action to display the list again. But
the details I don't have at this point.

Thanks for any help,
gk



> Gene K. wrote:
>> Hi,
>> While viewing part of a long list of records, the user may want to do a
>> Find of a specific record (for example, find_by_name). The found record
>> is then displayed using the list view. I've searched the wiki and
>> couldn't find a sample or information that will help directly in
>> implementing this function. Any pointers?
>> Thanks!
>> gk
>>
>>
>  Could you pass the name through the query string, and if that string is
> present just overwrite the value
> in the list @ variable with a find(:all, :conditions => ["name =
> ?",params[:name]])?
>
> --
> Matthew Wastrodowski
> Web D.
> http://blog.familopia.com
>
> removed_email_address@domain.invalid
> 949 395-7215
This topic is locked and can not be replied to.