Complex forms in a simpler way?

I have a form which updates across several models, and most of the
time what is covered is close to the railscast example (complex
forms), for adding photos etc, but i have another example trying to
use the field_for for a seemingly one to one relationship…

ie My form has a bunch of fields in one model, but two fields for
price both high and low in a second model. There can only be one
price or high and low added per form, but it is not a one to one
relationship because the price can change over time which is added

How can I do this?



class Price < ActiveRecord::Base
has_many :records
has_many :bubbles


@price =

<% form_for @price do |f| %>
<%= f.error_messages %>

<%= f.label :artist %>
<%= text_field_with_auto_complete :price, :artist, :autocomplete => "off", :size => "30" %>

..... .....
<% for bubble in @price.bubbles %>
<% fields_for "price[bubble]", bubble do |e| %>
    <%= e.label :price %><br />
      <%= e.text_field :low, :size => "4" %>-<%=

e.text_field :high, :size => “4” %>

<% end %>
<% end %>

Nevermind just did it thru the controller:

def new
@price =
@bubble =

def create
@price =[:price])
@bubble =[:bubble])

<% fields_for :bubble do |e| %>

<%= e.label :price %> $(10-25)

$<%= e.text_field :low, :size => “4” %>-<%=
e.text_field :high, :size => “4” %>

<% end %>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs