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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:54:28+00:00 2026-05-27T07:54:28+00:00

“enter code here<%= form_for(@person) do |f| %> <% if @person.errors.any? %> <div id=error_explanation> <h2><%=

  • 0
``enter code here<%= form_for(@person) do |f| %>
  <% if @person.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@person.errors.count, "error") %> prohibited this person from being saved:</h2>

      <ul>
      <% @person.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= f.label :name %><br />
    <%= f.text_field :name %>
  </div>
  <div class="field">
    <%= f.label :country_id %><br />
    <%= f.collection_select :country_id, Country.all(:order => "name"), :id, :name, :prompt => "-- Select a Country --"%>
    <%= observe_field (:person_country_id, :url => {:action => "update_state_div"}, :with => 'person_country_id'%>
  </div>
  <div class="field">
    <%= f.label :state_id %><br />
    <%= f.collection_select :state_id, State.all(:order => "name"), :id, :name, :prompt => "-- Select a State --"%>


    <%observe_field 'person_country_id', :url => {:action => "update_state_div"}, :with => 'person_country_id'%>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

please there seem to be somthing wrong with the observe_field, what i was expecting it to do was when i put in a value for country, the states under that country shows up

  • 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-27T07:54:29+00:00Added an answer on May 27, 2026 at 7:54 am

    It looks like you made an error where you embed the Ruby: <% observe_field %> inserts nothing, while <%= observe_field %> inserts the output from the function.

    Try this:

    <%= observe_field 'person_country_id', :url => {:action => "update_state_div"}, :with => 'person_country_id'%>
    

    Edit:

    observe_field was included to supplement Prototype, a javascript library not included in Ruby on Rails 3. This question also addresses this issue: Observe_field in rails 3.

    If you want to use it, you can install this plugin by typing

    rails plugin install git://github.com/rails/prototype_legacy_helper
    

    into the console.

    This seems to not be compatible with jQuery, so you might have to remove jQuery, or write your own javascript to do what you want.

    Yet another edit:

    This question addresses the issue in normal JavaScript/jQuery and HTML: jQuery Chaining Country / State Selects with OptGroup. You should be able to modify it for Ruby on Rails.

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

Sidebar

Related Questions

I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm using this code to make #sidebar 's height match #post_content 's height: <script
I want to change all headers, normally this is quite easy (and it probably
I'm looking for a way to convert text like this: <!DOCTYPE html PUBLIC \-//W3C//DTD
In following code, the usage of the string (i.e. a left double quotation mark
In the following code I am trying to get the select box to display
I am using custom code to print the comments but the problem is whatever
Does anyone know how can I replace this 2 symbol below from the string
I've put together this small little piece but I'm having problems with the renderings
I have a custom converter to select a Country in a SelectOneMenu component: File:

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.