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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:42:52+00:00 2026-05-12T17:42:52+00:00

Say I have controllers Apples and Bees, and new actions in both. In Bee’s

  • 0

Say I have controllers Apples and Bees, and new actions in both. In Bee’s new action, I set some variables for display in ‘bees/new’. I happen to also want to render this same template from Apples’s new method. What’s the correct way of setting up the variables in this case? I take it copying over the assignments from Bees isn’t the right way of going about it.

  • 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-12T17:42:53+00:00Added an answer on May 12, 2026 at 5:42 pm

    If you’re going to be displaying it in more than one place, your best bet is to use a partial. You can move all relevant view code into a partial (let’s call it “apples_new”, which means you’d save it as /app/views/apples/_apples_new.html.erb).

    Then, in your regular apples/new.html.erb view you can just call that partial:

    <!-- /app/views/apples/new.html.erb -->
    <h1>Apples New</h1>
    <%= render :partial => "apples_new" %>
    

    And in your Bees “new” view, you can do:

    <!-- /app/views/bees/new.html.erb -->
    <h1>Bees New</h1>
    <% if @bees.has_apples? $>
      <%= render :partial => "apples/apples_new" %>
    <% end %>
    

    Note that in my example above, I’m adding some logic. I’m assuming you only want to call the same form in certain scenarios, so I added the “has_apples?” method to demonstrate the logic.

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

Sidebar

Related Questions

lets say I have two methods in my controller to support both json and
Let's say I have 2 controllers, content and news: class ContentController extends Zend_Controller_Action {
I am having a problem with using session variables. I have two controllers named
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
I have two controllers, say controllerA and controllerB. ControllerA has a consultation object that
Lets say that I have 4 view controllers (call them FirstView,SecondView,ThirdView,FourthView) which are created
Let's say I have settings classes in my controllers and models, in my Java/Spring/MVC
Thank you for helping me understand some of this stuff: Say I have 2
Say I have two view controllers: xVC and yVC. I have used the shake
lets say i have two view controllers, firstViewController and secondViewController. The firstViewController is supposed

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.