Drop Down

Hey I'm new to rails and I'm looking to create a drop down for "name" in the estsydemo? I then want to order my listings by "name" in ABC order? Any good advice or links would be greatly appreciated!

Posted over 3 years ago by Corey Shaw
Posted over 3 years ago by Alex Yang

Hey Corey, are you looking to create a dropdown menu containing information/links, or are you trying to create a dropdown menu as part of a form? I'm assuming you trying to do the former.

The easiest way to create a dropdown menu is to use Bootstrap. Here's the link containing the code you can customize:

To order your listings, you'll need to modify the code in your controller file. For example, if you're trying to change the order on the Listings Index page, you should go to the 'index' action of your ListingsController and revise your definition of the @listings variable. It should look something like this:
@listings = Listing.all.order("name ASC")

Here, 'ASC' is short for 'ascending'. Finally, here's a helpful link for you to better understand ordering in Rails: