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

  • Home
  • SEARCH
  • 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 771519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:40:00+00:00 2026-05-14T18:40:00+00:00

For example, I might have an partial something like: <div> <%= f.label :some_field %><br/>

  • 0

For example, I might have an partial something like:

<div>
  <%= f.label :some_field %><br/>
  <%= f.text_field :some_field %>
</div>

which works for edit AND new actions. I also will have one like:

<div>
  <%=h some_field %>
</div>

for the show action. So you would think that all your partials go under one directory like shared or something. The problem that I see with this is that both of these would cause a conflict since they are essentially the same partial but for different actions so what I do is:

<!-- for edit and new actions -->
<%= render "shared_edit/some_partial" ... %>

<!-- for show action -->
<%= render "shared_show/some_partial" ... %>

How do you handle this? Is a good idea or even possible to maybe combine all of these actions into one partial and render different parts by determining what the current action is?

  • 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-14T18:40:00+00:00Added an answer on May 14, 2026 at 6:40 pm

    When I use shared directory, then inside I put model name and my partials have names like this:

    shared/person/_show.html.erb
    shared/person/_form.html.erb
    

    If you want to have one line to render form or show partial, then you can add helper:

    def render_form_or_show(model)
      if edit? || new? 
        return render :partial => "shared/#{model}/form"
      elsif show?
        return render :partial => "shared/#{model}/show"
      end
      return ""
    end
    

    If you fallow some rules, like putting your partials in shared directory and then in model directory, and then always have _form for edit and new, and _show for show action, then it will work ;). Of course you need to define edit? etc. methods:

    # Application controller
    def edit?
      params[:action] == 'edit'
    end
    

    Or maybe there is better way to get action name :).

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

Sidebar

Related Questions

EDIT: My example might have created some confusion. I have changed the example below
If I'm making a simple grid based game, for example, I might have a
We have some tables, which have a structure like: start, -- datetime end, --
Does anyone have any examples or resources where i might find information on scrolling
For example for the following XML <Order> <Phone>1254</Phone> <City>City1</City> <State>State</State> </Order> I might want
Example: You have a shortcut s to SomeProgram in the current directory. In cmd.exe
Example I have Person , SpecialPerson , and User . Person and SpecialPerson are
example: a_list = [1, 2, 3] a_list.len() # doesn't work len(a_list) # works Python
I have a data model in Doctrine/symfony. I have a 'Course' which has many
Based on their work, how do you distinguish a great SQL developer? Examples might

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.