Q:

How can I add an associated record from another records edit page?

I'm super new to programming and rails. I have a table of venues and a table of offers. A venue can have many offers and an offer belongs to one venue. 
I would like to be able to add offers to venues whilst on the venues edit.html.erb page. How can I do this? I thought the code I have already would work but its not saving anything and not giving any errors.
Venues model
class Venue < ActiveRecord::Base
  has_many :offers
end

Offers model
class Offer < ActiveRecord::Base
  belongs_to :venue
end

Venues controller
  def edit
    @venue = Venue.find(params[:id])    
    @offer = Offer.new
  end

Offers controller
class OffersController < ApplicationController

  def new
    @offer = Offer.new
  end

  def create
    @offer = @venue.offers.create!(params[:offer])
    @offer.venue = @venue
    if @offer.save
      flash[:notice] = 'Offer added'
      redirect_to :back
    else
      render :action => :new
    end
  end
end

Venues edit.html.erb 
<div id="tabs-3">
  <%= form_for @venue do |f| %>
    <div class="edit_venue_details">

      <h2 class="edit_venue_header">Offers</h2>

      <% if @venue.offers.count.zero? %>
        <div class="no_offers">
          No offers added yet.
        </div>
      <% else %>
        <%= render :partial => 'offers/offer', :collection => @venue.offers %>
      <% end %>    
      <div class="clearall"></div>
    </div>

    <h2 class="edit_venue_sub_header">Add a new offer</h2>

    <%= form_for @offer do |offer| %>
      <p class="edit_venue">title: <br>
      <%= offer.text_field :title, :class => "edit_venue_input" %></p>
      <button class="submit_button" type="submit"> Save changes</button>
    <% end %>
  <% end %>
</div>

Thanks for any help its much appreciated!

A:

Your going to use the Rails' concepts o f nested attributes and the form.fields_for method. See docs.
In your case, it should be something like:
Model
class Venue < ActiveRecord::Base
  has_many :offers
  accepts_nested_attributes_for :offers
end

View
...
<%= f.fields_for :venues, @venue.offers.new do |offer_fields| %>
  <%= offer_fields.text_field :title %>
<% end %>
...

