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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:51:23+00:00 2026-05-20T10:51:23+00:00

I would be grateful if someone could help me out with this. In my

  • 0

I would be grateful if someone could help me out with this.

In my RoR application, i have a form where based on the value entered in a field, the rest of the form fields are displayed accordingly. Please find my code below

Form Code:

<p> Location: <%= f.text_field :LOC %></p>


<% f.fields_for :detail do |builder| %>
<p> Type: <%= builder.select(:DET_TYPE, [['Type A', 'Type A'],
                                         ['Type B', 'Type B'],
                                        ],{ :prompt => "Please select"}
                                        ) %>
</p>

<%= observe_field("sub_detail_DET_TYPE", :frequency => 1,
:url => { :controller => 'references', :action => :display_prod_method },
:with => "'id='+value") %>

<div id="div1"></div>

<% end %>

In my references controller:

def display_prod_method
  @type = (params[:id])
end

display_prod_method.rjs:

page.replace_html "div1", :partial => "prodMethod"

_prodMethod.html.erb partial:

<% if @type == "Type A" %>
<p>Production Method: <%= builder.select(:PROD_METHOD, [['Method A', 'Method A'],
                                                  ['Method B', 'Method B'],
                                                  ],{ :prompt => "Please select"}
                                                  ) %>
</p>
 <% end %>

The thing is that if there is only text in the partial, it is rendered in my main form when i select ‘Type A’. However when i put the code below in the partial, it is not displayed at all –

<%= builder.select(:PROD_METHOD, [['Method A', 'Method A'],
                                                      ['Method B', 'Method B'],
                                                      ],{ :prompt => "Please select"}
                                                      ) %>

Please can someone shed some light on this for me.

Thanks a lot for your help 🙂

  • 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-20T10:51:24+00:00Added an answer on May 20, 2026 at 10:51 am

    that’s because you haven’t access to a form builder in your partial. Because there is no form_for around it.

    So you should go for the static tag function.

    Put this in your partial:

    <%= select_tag :prod_method, [['Method A', 'Method A'],['Method B', 'Method B']], { :prompt => "Please select"} %>  
    

    Spend attention on the naming, maybe you have to adjust this because it’s encapsulated in fields_for.

    Edit:

    Actually your attempt should produce an error, check your rails server console for that because the error won’t be visible in your browser because of the AJAX call.

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

Sidebar

Related Questions

I would be very grateful if someone could help me with this. I have
I would be so very grateful if someone could help me out! I have
This is driving me crazy. Very grateful if someone could help me out! Problem:
I would be very grateful if someone could help me break through this issue
I would be grateful if someone could help me out here. I'm just starting
I am actually new at Qt and would be grateful if someone could explain
I really hope someone will be able to help me out with this. I
wondering if someone could help me, but at the same time hopefully I can
Rails 3.1.3 and/or 3.2.2. I am unable to determine the cause, would be grateful
Would anyone be able to tell me how to pull the server name out

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.