Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 728201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:39:15+00:00 2026-05-14T06:39:15+00:00

Wow, switching to REST is a different paradigm for sure and is mainly a

  • 0

Wow, switching to REST is a different paradigm for sure and is mainly a headache right now.

view

<% form_tag (businesses_path, :method => "get") do %>
<%= select_tag :business_category_id, options_for_select(@business_categories.collect     {|bc| [bc.name, bc.id ]}.insert(0, ["All Containers", 0]),  which_business_category(@business_category) ), { :onchange => "this.form.submit();"} %>
<% end %>

controller

def index
@business_categories = BusinessCategory.find(:all)
if params[:business_category_id].to_i != 0
  @business_category = BusinessCategory.find(params[:business_category_id])
  @businesses = @business_category.businesses
else
 @businesses = Business.all 
end
respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @businesses }
end

end

routes

map.resources 

What I want to to is get a better URL than what this form is presenting which is the following:
http://localhost:3000/businesses?business_category_id=1

Without REST I would have do something like
http://localhost:3000/business/view/bbq bbq as permalink or I would have done http://localhost:300/business_categories/view/bbq and get the business that are associated with the category but I don’t really know the best way of doing this.

So the two questions are what is the best logic of finding a business by its categories using the latter form and number two how to get that in a pretty URL all through RESTful routes in Rails.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:39:16+00:00Added an answer on May 14, 2026 at 6:39 am

    If you have more info to share about the business category beside just listing them all, you can use the ‘show’ of a business category

    http://localhost:300/business_categories/1

    If you want it to have a meaningful name instead of “1” (like the name of the category) you can use friendly_id plugin, that does just that 🙂

    class BusinessCategory < ActiveRecord::Base
      has_friendly_id :name, :use_slug => true
    end
    

    Then you can use http://localhost:300/business_categories/bbq

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wow, I'm having a bit of a headache with Access 2007. I have two
I'm writing a simple GB emulator (wow, now that's something new, isn't it), since
Wow now i know I dont. Lol. I've got my structure like this: struct
EDIT: WOW. This question is 12 years old now. As someone stated, it can
Wow, this seems so basic, but I can't get it to work. All I
Wow, that title was a mouthful... I'm sure that sounds very confusing at first
Wow...I've never seen this before. Any way to get around it? foreach( double r
Wow, never thought I would ever write anything in DOS. Now that I do,
Wow, what a mess. This is the scenario. Backbone driven JS app. RequireJS for
Wow crazy title! But here's the problem. In efforts to dry up my school

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.