I'm maintaining a Rails 2.0 app for a non-profit. I've added a text 
field to the user model to hold a note. I want the contents of the 
current user's note field to populate the form so it can be modified 
if desired.

My understanding is that is what Rails does by default. I've removed 
almost everything from the layout and view (a comment in layout.rb 
says: NOTE: The old notation for rendering the view from a layout was 
to expose the magic <tt>@content_for_layout</tt> instance variable. 
The preferred notation now is to use <tt>yield</tt>, as documented above.)

Here's the layout:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
         <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<div id="content">
   <%= @content_for_layout %>
</div>
</body>
</html>

Here's the view:

<% form_for :user, @user, :url => { :action => "save_notes", :id => 
@user.id }, :id => "save_notes", :class => "notes" do |form| %>
   <%= form.text_field :notes %>
   <%= submit_tag("Save", :style => 'float:right;margin-right:1em;') %>
<% end %>

Here's the HTML. Note there is no CSS or Javascript:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
</head>
<body>
<div id="content">
   <form action="/admin/members/save_notes/3782" method="post">
     <input id="user_notes" name="user[notes]" size="30" type="text" 
value="This is a test." />
     <input name="commit" type="submit" value="Save" />
   </form>
</div>
</body>
</html>

The problem occurs when this page is displayed on localhost, running 
under development. The text field is not populated with 'This is a 
test' in Firefox under Linux.

If I copy the HTML to a file and browse to that, it is populated.

If I run the app under OnCloud.org (what a great way to show clients 
work-in-progress) and view from either Linux or Windoze, the field is 
populated.

Why isn't the field populated when the app is accessed via localhost?

Thanks,

Scott

--~--~---------~--~----~------------~-------~--~----~
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby
-~----------~----~----~----~------~----~------~--~---

Reply via email to