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.
E4b8c35c29cfcaea3c2101193417466b?d=identicon&s=25 Gene Kahn (kublai)
on 2006-05-29 07: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
E99c0e343d07bb1f07c60f755424bca7?d=identicon&s=25 Matthew Wastrodowski (Guest)
on 2006-05-29 09:13
(Received via mailing list)
Gene Kahn 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 Developer
http://blog.familopia.com

mwastrod@uci.edu
949 395-7215
73606b1d1042de19056f3d59492b652f?d=identicon&s=25 Charlie Bowman (beachguy82)
on 2006-05-29 14: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 Bowman
http://www.recentrambles.com
E4b8c35c29cfcaea3c2101193417466b?d=identicon&s=25 Gene Kahn (kublai)
on 2006-05-29 16: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 Bowman
> 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
E4b8c35c29cfcaea3c2101193417466b?d=identicon&s=25 Gene Kahn (kublai)
on 2006-05-29 17: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 Kahn 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 Developer
> http://blog.familopia.com
>
> mwastrod@uci.edu
> 949 395-7215
This topic is locked and can not be replied to.