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 -- Posted via http://www.ruby-forum.com/.
Matthew Wastrodowski
2006-May-29 07:11 UTC
[Rails] Prompting user to enter value to feed Find
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
charlie bowman
2006-May-29 12:41 UTC
[Rails] Re: Prompting user to enter value to feed Find
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 -- Posted via http://www.ruby-forum.com/.
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.comAwesome! 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 -- Posted via http://www.ruby-forum.com/.
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-- Posted via http://www.ruby-forum.com/.