I have two models
class Office < ActiveRecord::Base has_many :locations, :dependent => :destroy end class Location < ActiveRecord::Base belongs_to :office end
I have new.html.erb for an office model and below code in OfficeController
def create @office = Office.new(params[:deal]) if @office.save redirect_to office_url, :notice => "Successfully created office." else render :action => 'new' end end
How to add fields for Location model in new.html.erb from Office ?
I want to have fields for locations in the same form.
source share