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 725621
In Process

The Archive Base Latest Questions

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

Maybe my logic is not restful or know if this is how you would

  • 0

Maybe my logic is not restful or know if this is how you would do it but this is what I am trying to do.

I’m getting a category inside a category controller and then once I get that category I want to return to an index page in a different controller but keep that @category and the Category.busineses.

Before rest I would have just done this:

render :controller => “businesses”

and it would have rendered the view of the index action in that controller.

now in my respond_to block I have this

   format.html {redirect_to(business_path)} # index.html.erb
   format.xml  { render :xml => @businesses }

but of course with a render it looses the instance variable and starts with a new action.

So what I want to do is render the action instead of redirecting to that action.
is this possible?

Should i just replace the respond_to with render :controller => ?

  • 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:21:28+00:00Added an answer on May 14, 2026 at 6:21 am

    I think what you are trying to do (if I understand it correctly) would be best achieved using nested resources. If there are businesses separated into categories, and you want to display a listing of all businesses in a specific category, you could set up your application like this:

    Models

    class Category < ActiveRecord::Base
      has_many :businesses
    end
    
    class Business < ActiveRecord::Base
      belongs_to :category
    end
    

    Routes

    map.resouces :businesses
    
    map.resources :categories do |categories|
      categories.resources :businesses
    end
    

    Controller

    class BusinessesController < ApplicationController
      def index
        @category = Category.find(params[:category_id]) if params[:category_id]
        conds = params[:category_id] ? { :category_id => params[:category_id] } : nil
        @businesses = Business.all(:conditions => conds)
      end
    end
    

    Then simply access the list of a category’s businesses like this: /category/1/businesses

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

Sidebar

Related Questions

Maybe it is science fiction, but i would like to know if it is
Maybe this has already been answered and I am searching incorrectly, but here is
Maybe I am implementing WCF improperly, but I seem to be getting a WCF
Maybe I just don't know .NET well enough yet, but I have yet to
Maybe the need to do this is a 'design smell' but thinking about another
I have some rendering logic for custom markup (a'la bbcode, but not bbcode). So
I would like to know if maybe there are some good solutions to handling
I have a lot of methods (in this case, from web services, but maybe
Maybe this is a dumb question, but when should you map a column into
i am new to WPF so maybe this will be noob question but i

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.