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)
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.
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
[email protected] 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 :
How to paginate, sort and search a table with Ajax and Rails · dev.nozav.org
That page is for an older version of rails I think, but the concepts are
the same.
Chris
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 L. [email protected]
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, “[email protected]”
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, “[email protected]”
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, “[email protected]”