jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-11 17:28 UTC
BeginnerQ: Combining a form_for with find() to search mysql
I''ve looked over the AgileROR section on forms and the secion on find() but I am still a bit confused. What I want to do it pretty simple: I''ve got my inventory listing working and at the top I want the user to be able to narrow the listing based on a few columns in the database using a select form. I.E., I have a select pull-down that lists all of the makes in the :make column in the database (and doesn''t list the same make twice) and the user can select one of the makes and hit submit, then the user is given the inventory listing with just those makes. Most of the search related documentation seems to deal with fulltext search, which is not what I want. Just a select for :make, :model, :price and :carvantrucksuv -- I know how to define :choices for :price and :carvantrucksuv in the model. But I can''t seem to get the form or the dynamic list for make and model to work. (I think I use :action => :create but I''m pretty lost) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Lowis
2007-Apr-12 13:47 UTC
Re: BeginnerQ: Combining a form_for with find() to search my
> Just a select > for :make, :model, :price and :carvantrucksuv -- I know how to > define :choices for :price and :carvantrucksuv in the model. But I > can''t seem to get the form or the dynamic list for make and model to > work. (I think I use :action => :create but I''m pretty lost)I think you want the form.select method in your view. http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M000506 Since you have the Agile web development book, I''ll refer you to page number 485, under "selection lists" (that''s in the 2nd edition of the book). Best regards, Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Lowis
2007-Apr-12 14:51 UTC
Re: BeginnerQ: Combining a form_for with find() to search my
jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I''ve looked over the AgileROR section on forms and the secion on > find() but I am still a bit confused. What I want to do it pretty > simple: I''ve got my inventory listing working and at the top I want > the user to be able to narrow the listing based on a few columns in > the database using a select form. I.E., I have a select pull-down > that lists all of the makes in the :make column in the database (and > doesn''t list the same make twice) and the user can select one of the > makes and hit submit, then the user is given the inventory listing > with just those makes. Most of the search related documentation seems > to deal with fulltext search, which is not what I want. Just a select > for :make, :model, :price and :carvantrucksuv -- I know how to > define :choices for :price and :carvantrucksuv in the model. But I > can''t seem to get the form or the dynamic list for make and model to > work. (I think I use :action => :create but I''m pretty lost)On closer reading, I think you might want to do something like this : http://dev.nozav.org/rails_ajax_table.html That page is for an older version of rails I think, but the concepts are the same. Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-12 15:43 UTC
Re: BeginnerQ: Combining a form_for with find() to search my
I think that might work, I''m going to give it a try. I was going to try and do it without AJAX, but since it doesn''t seem to be spelled out anywhere else using just a simple form, AJAX is fine. Although I''ll have to figure out something with price constraints form.select. On Apr 12, 10:51 am, Chris Lowis <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > I''ve looked over the AgileROR section on forms and the secion on > > find() but I am still a bit confused. What I want to do it pretty > > simple: I''ve got my inventory listing working and at the top I want > > the user to be able to narrow the listing based on a few columns in > > the database using a select form. I.E., I have a select pull-down > > that lists all of the makes in the :make column in the database (and > > doesn''t list the same make twice) and the user can select one of the > > makes and hit submit, then the user is given the inventory listing > > with just those makes. Most of the search related documentation seems > > to deal with fulltext search, which is not what I want. Just a select > > for :make, :model, :price and :carvantrucksuv -- I know how to > > define :choices for :price and :carvantrucksuv in the model. But I > > can''t seem to get the form or the dynamic list for make and model to > > work. (I think I use :action => :create but I''m pretty lost) > > On closer reading, I think you might want to do something like this : > http://dev.nozav.org/rails_ajax_table.html > > That page is for an older version of rails I think, but the concepts are > the same. > > Chris > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-12 16:27 UTC
Re: BeginnerQ: Combining a form_for with find() to search my
Crazy thing, I can search it now but AJAX doesn''t seem to be working: I have to enter the text in the box and hit enter. Ah! On Apr 12, 11:43 am, "jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think that might work, I''m going to give it a try. I was going to > try and do it without AJAX, but since it doesn''t seem to be spelled > out anywhere else using just a simple form, AJAX is fine. Although > I''ll have to figure out something with price constraints form.select. > > On Apr 12, 10:51 am, Chris Lowis <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > I''ve looked over the AgileROR section on forms and the secion on > > > find() but I am still a bit confused. What I want to do it pretty > > > simple: I''ve got my inventory listing working and at the top I want > > > the user to be able to narrow the listing based on a few columns in > > > the database using a select form. I.E., I have a select pull-down > > > that lists all of the makes in the :make column in the database (and > > > doesn''t list the same make twice) and the user can select one of the > > > makes and hit submit, then the user is given the inventory listing > > > with just those makes. Most of the search related documentation seems > > > to deal with fulltext search, which is not what I want. Just a select > > > for :make, :model, :price and :carvantrucksuv -- I know how to > > > define :choices for :price and :carvantrucksuv in the model. But I > > > can''t seem to get the form or the dynamic list for make and model to > > > work. (I think I use :action => :create but I''m pretty lost) > > > On closer reading, I think you might want to do something like this : > > http://dev.nozav.org/rails_ajax_table.html > > > That page is for an older version of rails I think, but the concepts are > > the same. > > > Chris > > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-12 16:51 UTC
Re: BeginnerQ: Combining a form_for with find() to search my
Bam! Got it! Just forgot a <%= javascript_include_tag :defaults %>. It works great. Results like this make me want to continue learning how to program. Now I''ve just got to figure out how to combine two or three of these to narrow the results. On Apr 12, 11:43 am, "jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think that might work, I''m going to give it a try. I was going to > try and do it without AJAX, but since it doesn''t seem to be spelled > out anywhere else using just a simple form, AJAX is fine. Although > I''ll have to figure out something with price constraints form.select. > > On Apr 12, 10:51 am, Chris Lowis <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > I''ve looked over the AgileROR section on forms and the secion on > > > find() but I am still a bit confused. What I want to do it pretty > > > simple: I''ve got my inventory listing working and at the top I want > > > the user to be able to narrow the listing based on a few columns in > > > the database using a select form. I.E., I have a select pull-down > > > that lists all of the makes in the :make column in the database (and > > > doesn''t list the same make twice) and the user can select one of the > > > makes and hit submit, then the user is given the inventory listing > > > with just those makes. Most of the search related documentation seems > > > to deal with fulltext search, which is not what I want. Just a select > > > for :make, :model, :price and :carvantrucksuv -- I know how to > > > define :choices for :price and :carvantrucksuv in the model. But I > > > can''t seem to get the form or the dynamic list for make and model to > > > work. (I think I use :action => :create but I''m pretty lost) > > > On closer reading, I think you might want to do something like this : > > http://dev.nozav.org/rails_ajax_table.html > > > That page is for an older version of rails I think, but the concepts are > > the same. > > > Chris > > > -- > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
jamesdylangoldstein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Apr-12 19:01 UTC
Re: BeginnerQ: Combining a form_for with find() to search my
One hitch: Enter the maximum price: *TEXTBOX* Code: conditions = ["price < ?", "%#{@params[:query]}%"] unless @params[:query].nil? Doesn''t work, I''ve got the code wrong. On Apr 12, 12:51 pm, "jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Bam! Got it! Just forgot a <%= javascript_include_tag :defaults %>. > It works great. Results like this make me want to continue learning > how to program. Now I''ve just got to figure out how to combine two or > three of these to narrow the results. > > On Apr 12, 11:43 am, "jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > <jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I think that might work, I''m going to give it a try. I was going to > > try and do it without AJAX, but since it doesn''t seem to be spelled > > out anywhere else using just a simple form, AJAX is fine. Although > > I''ll have to figure out something with price constraints form.select. > > > On Apr 12, 10:51 am, Chris Lowis <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > > > > jamesdylangoldst...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > I''ve looked over the AgileROR section on forms and the secion on > > > > find() but I am still a bit confused. What I want to do it pretty > > > > simple: I''ve got my inventory listing working and at the top I want > > > > the user to be able to narrow the listing based on a few columns in > > > > the database using a select form. I.E., I have a select pull-down > > > > that lists all of the makes in the :make column in the database (and > > > > doesn''t list the same make twice) and the user can select one of the > > > > makes and hit submit, then the user is given the inventory listing > > > > with just those makes. Most of the search related documentation seems > > > > to deal with fulltext search, which is not what I want. Just a select > > > > for :make, :model, :price and :carvantrucksuv -- I know how to > > > > define :choices for :price and :carvantrucksuv in the model. But I > > > > can''t seem to get the form or the dynamic list for make and model to > > > > work. (I think I use :action => :create but I''m pretty lost) > > > > On closer reading, I think you might want to do something like this : > > > http://dev.nozav.org/rails_ajax_table.html > > > > That page is for an older version of rails I think, but the concepts are > > > the same. > > > > Chris > > > > -- > > > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---