Question: I have two models in Rails 3 - a User model and a Profile model.

```
class User < ActiveRecord::Base
  has_one :profile, :dependent => :destroy
end

class Profile < ActiveRecord::Base
  belongs_to :user
end

```

They are scoped in my routes.rb file, as such:

```
resources :users do
  resources :profiles
end

```

So now, my form to create a profile reads like this (Using SimpleForm):

```
<%= simple_form_for([@user, @profile]) do |f| %>
  <%= f.error_notification %>
    ...(Other Inputs)
<% end %>

```

However, the user ID doesn't seem to be automatically sent to the profile model as I had assumed. Do I have to set that manually through the controller? Or am I missing something?

Answer: 
Try like this.

```
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
</head>
<body>
<table>
<tr>
    <td>Celsius</td>
    <td>Fahrenheit</td>
</tr>
<script type="text/javascript" > //<![CDATA[
    for (var celsius = 0; celsius <= 50; celsius++) {
        document.write("<tr><td>"+ celsius +"</td>");
        document.write("<td>"+ ((celsius*9/5)+32) +"</td></tr>");
}
//]]></script>
</table>
</body>
</html>

```
You should call a javascript function when document has been loaded:

```
if (document.readyState === "complete") { loadTemperatures(); }

```

Your loadTemperatures function will append rows to your table. Have a look here to learn how to do that:
<http://viralpatel.net/blogs/dynamically-add-remove-rows-in-html-table-using-javascript/>

> 
> Element script not allowed as child of element tbody in this context
> 
> 
> 

Put the `<script>` balise between `<head>` and `</head>` to correct that.

Here is a jsFiddle to show you the goal: <http://jsfiddle.net/dfTz6/2/>