<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Creating Two Models in One Form]]></title>
		<link>http://railsforum.com/viewtopic.php?id=717</link>
		<description><![CDATA[The most recent posts in Creating Two Models in One Form.]]></description>
		<lastBuildDate>Mon, 12 Nov 2012 04:48:13 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=156995#p156995</link>
			<description><![CDATA[<p>This post helped in learning how to handle multiple models in a rails form. It works as long as the models are nested. what if they are not? lets say, I have a form, where the user fills personal details, address details and a bunch of checkboxes specifying her interests. There are at least 3 tables involved in this one single form</p><p><a href="http://www.karneval-fasching-kostuem-kostueme.de/">Faschingskostüm</a><br /><a href="http://www.familienladen24.de/karneval-fasching-0-12/">für fasching</a><br /><a href="http://www.karneval-fasching-kostueme.de/kostueme-kinder.html">karneval fasching</a></p>]]></description>
			<author><![CDATA[dummy@example.com (Adam Overmiller)]]></author>
			<pubDate>Mon, 12 Nov 2012 04:48:13 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=156995#p156995</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=156953#p156953</link>
			<description><![CDATA[<p>Thanks for the post but I&#039;d like to know how folks would do something like this with ActiveModel.To go back to the original post would you do this instead?</p><div class="codebox"><pre><code>def create  
@task = Task.new(params[:task])  
@project = Project.new(params[:project], @task) 
if @project.save    
redirect_to :action =&gt; &#039;index&#039;  
else    
render :action =&gt; &#039;new&#039;  
end
end</code></pre></div><p>or stick with the same approach but inside the Project class have a tasks method that returns a new instance of Tasks that contains a build method.&nbsp; Thoughts?</p><p>Thanks in advance.</p>]]></description>
			<author><![CDATA[dummy@example.com (perryjason)]]></author>
			<pubDate>Fri, 09 Nov 2012 15:30:23 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=156953#p156953</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=149552#p149552</link>
			<description><![CDATA[<p>How does one do the exact opposite of this (wonderful!) tutorial? I need one model form to draw from another model and save the foreign key:</p><p>Here&#039;s my SO posting for this question:<br /><a href="http://stackoverflow.com/questions/9236530/combine-multiple-models-in-a-rails-form-to-create-a-new-object">http://stackoverflow.com/questions/9236 &#133; new-object</a></p><p>I have two models, Story and Category. Using the form for Story#new, I&#039;d like to be able to save the foreign key for Category.</p><p>To display the selection data from Category on the Story#new form page I&#039;ve used:<br /></p><div class="codebox"><pre><code>&lt;%= collection_select(:category , :category, Category.all , :id, :category, {:prompt =&gt; &#039;Select Category...&#039;}) %&gt;</code></pre></div><p>How can I save category_id to the newly created Story object?Story has attributes: industry_id and user_id, Category has attribute name development.log tells me this: (it looks like it&#039;s trying to add a new category (99) to the Categories table:</p><div class="codebox"><pre><code>Started POST &quot;/stories&quot; for 127.0.0.1 at 2012-02-10 17:32:56 -0600
 Processing by StoriesController#create as HTML
story&quot;=&gt;{&quot;industry_id&quot;=&gt;&quot;8&quot;, &quot;user_id&quot;=&gt;&quot;8&quot;}, &quot;category&quot;=&gt;{&quot;category&quot;=&gt;&quot;99&quot;}, &quot;commit&quot;=&gt;&quot;Create Story&quot;}</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (dgilliam12)]]></author>
			<pubDate>Sat, 11 Feb 2012 00:07:05 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=149552#p149552</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=145224#p145224</link>
			<description><![CDATA[<p><a href="http://lumbee-on-rails.blogspot.com/2011/11/create-multiple-models-in-single-form.html">http://lumbee-on-rails.blogspot.com/201 &#133; -form.html</a></p>]]></description>
			<author><![CDATA[dummy@example.com (lumbee)]]></author>
			<pubDate>Tue, 27 Sep 2011 00:11:21 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=145224#p145224</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=114223#p114223</link>
			<description><![CDATA[<p>I have gone through your example.<br />Its really very nice.</p><p>Can u provide me some more functionalities like Update and delete operations of multiple tables (models) through single form.</p><p>If we are able to perform these operations then only our article should be perfect right...!!</p><p>I looking for your reply.</p>]]></description>
			<author><![CDATA[dummy@example.com (kranthipoturaju)]]></author>
			<pubDate>Tue, 08 Dec 2009 09:31:47 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=114223#p114223</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=104353#p104353</link>
			<description><![CDATA[<p>Is there a more up-to-date tutorial?</p>]]></description>
			<author><![CDATA[dummy@example.com (cong06)]]></author>
			<pubDate>Tue, 21 Jul 2009 14:07:39 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=104353#p104353</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=96059#p96059</link>
			<description><![CDATA[<p>Hi all</p><p>I have 2 tables. Lesson and Tag. A lesson can have multiple tags. When I save, records are saving in both tables but the tag.body is saving as NULL. What am I doing wrong?</p><p>This is lesson,rb<br />class Lesson &lt; ActiveRecord::Base<br />#Mandatory fields validation<br />validates_presence_of :title, :contact_yn<br />has_many :tags<br />end</p><p>This is tag.rb<br />class Tag &lt; ActiveRecord::Base<br />&nbsp; &nbsp; belongs_to :lesson<br />end</p><p>My lesson.new is<br />&lt;h1&gt;New lesson&lt;/h1&gt;</p><p>&lt;%= error_messages_for :lesson %&gt;<br />&lt;%= error_messages_for :tag %&gt;</p><p>&lt;% form_for(@lesson) do |f| %&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= f.label :title %&gt;&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= f.text_field :title %&gt;<br />&nbsp; &lt;/p&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= f.label :description %&gt;&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= f.text_area :description %&gt;<br />&nbsp; &lt;/p&gt;</p><p>&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; Can others contact you?&lt;br /&gt;<br />&nbsp; &nbsp;&lt;%= f.select :contact_yn, [&#039;Yes&#039;, &#039;No&#039;] %&gt;<br />&nbsp; &lt;/p&gt;<br />&lt;% fields_for :tags do |i| %&gt;<br />&nbsp; &nbsp; &nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; Tags:&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= i.text_field :body %&gt;<br />&lt;/p&gt;<br />&lt;% end %&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= f.submit &#039;Save&#039; %&gt;<br />&nbsp; &lt;/p&gt;</p><p>&lt;% end %&gt;<br />&lt;%= link_to &#039;Back&#039;, lessons_path %&gt;</p><p>My lesson controller is<br />def new<br />&nbsp; &nbsp; @lesson = Lesson.new<br />&nbsp; &nbsp; @tag = Tag.new<br />&nbsp; &nbsp;<br />&nbsp; &nbsp; respond_to do |format|<br />&nbsp; &nbsp; &nbsp; format.html # new.html.erb<br />&nbsp; &nbsp; &nbsp; format.xml&nbsp; { render :xml =&gt; @lesson }<br />&nbsp; &nbsp; end<br />&nbsp; end</p><p>&nbsp; # GET /lessons/1/edit<br />&nbsp; def edit<br />&nbsp; &nbsp; @lesson = Lesson.find(params[:id])<br />&nbsp; end</p><p>&nbsp; # POST /lessons<br />&nbsp; # POST /lessons.xml<br />&nbsp; def create<br />&nbsp; &nbsp; @lesson = Lesson.new(params[:lesson])<br />&nbsp; &nbsp; $tag = @lesson.tags.build(params[:tag])</p><p>&nbsp; &nbsp; respond_to do |format|<br />&nbsp; &nbsp; &nbsp; if @lesson.save<br />&nbsp; &nbsp; &nbsp; &nbsp; flash[:notice] = &#039;Lesson was successfully created.&#039;<br />&nbsp; &nbsp; &nbsp; &nbsp; format.html { redirect_to(@lesson) }<br />&nbsp; &nbsp; &nbsp; &nbsp; format.xml&nbsp; { render :xml =&gt; @lesson, :status =&gt; :created, :location =&gt; @lesson }<br />&nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; format.html { render :action =&gt; &quot;new&quot; }<br />&nbsp; &nbsp; &nbsp; &nbsp; format.xml&nbsp; { render :xml =&gt; @lesson.errors, :status =&gt; :unprocessable_entity }<br />&nbsp; &nbsp; &nbsp; end<br />&nbsp; &nbsp; end<br />&nbsp; end</p><br /><p>When I save, records are saving in both tables but the tag.body is saving as NULL. What am I doing wrong?</p><p>TIA<br />-vas</p>]]></description>
			<author><![CDATA[dummy@example.com (vgulla)]]></author>
			<pubDate>Thu, 30 Apr 2009 21:26:47 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=96059#p96059</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=95239#p95239</link>
			<description><![CDATA[<p>Maybe a presenter - never used one myself, but I&#039;ve heard of stuff like this being done using such patterns.</p>]]></description>
			<author><![CDATA[dummy@example.com (mellifluidicpulse)]]></author>
			<pubDate>Thu, 23 Apr 2009 03:56:33 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=95239#p95239</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=95196#p95196</link>
			<description><![CDATA[<p>there are so many tutorials on how to create multiple models in one form, but i want to do something more simple and its killing me, i cant find ANY examples.&nbsp; How do you create multiple instances of the SAME model on one form.&nbsp; Say you wanted a tasks entry screen where you could enter 4 tasks in one view and submit and have them all created.&nbsp; What then? please help, ive wasted half the day on this</p>]]></description>
			<author><![CDATA[dummy@example.com (tmasterson)]]></author>
			<pubDate>Wed, 22 Apr 2009 20:18:34 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=95196#p95196</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=91389#p91389</link>
			<description><![CDATA[<p>Hi, I have two models. The parent model uses a sequence table for getting the primary key value, and the child model is joint with the parent model through the parent model&#039;s primary key.</p><p><pre name="code" class="ruby:nogutter">class Event &lt; ActiveRecord::Base<br />&nbsp; set_table_name &quot;er_event&quot;<br />&nbsp; set_sequence_name &quot;er_event_seqno&quot;<br />&nbsp; set_primary_key :eventid<br />&nbsp; has_many :product<br />end</p><br /><p>class Product &lt; ActiveRecord::Base<br />&nbsp; set_table_name &quot;er_product&quot;<br />&nbsp; set_primary_key :productid<br />&nbsp; belongs_to :event, :class_name =&gt; &quot;Event&quot;, :foreign_key =&gt; [:eventid]<br />end</pre><br />here it is my controller where I try to save these two models:</p><p><pre name="code" class="ruby:nogutter">class CreateController &lt; ApplicationController<br />&nbsp; def create<br />&nbsp; &nbsp; @event = Event.new(params[:er_event])<br />&nbsp; &nbsp; @product = @event.product.build(params[:product])<br />&nbsp; &nbsp; if @event.save<br />&nbsp; &nbsp; &nbsp; flash[:notice] = &#039;New promotion is created.&#039;<br />&nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; flash[:error] = &#039;Please correct the errors below:&#039;<br />&nbsp; &nbsp; end</p><p>&nbsp; &nbsp; render :action =&gt; &quot;index&quot;<br />&nbsp; <br />&nbsp; end<br />end</pre><br />but the problem now is the auto-generated eventid is not passed to the child model while saving. here is the log<br /><pre name="code" class="ruby:nogutter"> select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT er_product.productid FROM er_product WHERE (er_product.productid = &#039;P1&#039; AND er_product.eventid IS NULL) ) raw_sql_ where rownum &lt;= 1) where raw_rnum_ &gt; 0<br />&nbsp; Event Exists (2.2ms)&nbsp; &nbsp;select * from (select raw_sql_.*, rownum raw_rnum_ from (SELECT er_event.eventid FROM er_event WHERE (er_event.title = &#039;test&#039;) ) raw_sql_ where rownum &lt;= 1) where raw_rnum_ &gt; 0<br />Rendering template within layouts/application</pre><br />Does anyone has an idea how I can pass the value of the parent model primary key to the child model? Specifically the primary key is generated by sequence table. Thanks!</p>]]></description>
			<author><![CDATA[dummy@example.com (kuanfai)]]></author>
			<pubDate>Mon, 23 Mar 2009 05:34:30 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=91389#p91389</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=91121#p91121</link>
			<description><![CDATA[<p>Hi Javix,<br />thank you for the suggestions.</p><p>Now i have removed the use has_many:through association.<br />And i could able to upload stream into database.</p><p>But the problem here is:<br />while uploading data into other tables<br />1)i am not getting the transportstream_id from transportstreams in to the programs table.<br />2)throughing the error like:<br />ActiveRecord::StatementInvalid in Containerformats#show <br />Showing app/views/containerformats/show.html.erb where line #26 raised: </p><p>Mysql::Error: Unknown column &#039;programs.containerformat_id&#039; in &#039;where clause&#039;: SELECT * FROM `programs` WHERE (`programs`.containerformat_id = 2) </p><p>but data is storing in the correspomding tables.</p><p>my code details;</p><p>in containerformatcontroller:<br />def new<br />&nbsp; &nbsp; @containerformat = Containerformat.new<br />&nbsp; &nbsp; @containerformat.transport_streams.build<br />&nbsp; &nbsp; &nbsp;@containerformat.programs.build<br />&nbsp; &nbsp; &nbsp;@containerformat.streams.build</p><p>&nbsp; &nbsp; respond_to do |format|<br />&nbsp; &nbsp; &nbsp; format.html # new.html.erb<br />&nbsp; &nbsp; &nbsp; format.xml&nbsp; { render :xml =&gt; @containerformat }<br />&nbsp; &nbsp; end<br />&nbsp; end</p><p>--------in containerformat model<br />class Containerformat &lt; ActiveRecord::Base<br />has_many :transport_streams<br />has_many :programs<br />has_many :streams</p><p>def transport_stream_attributes=(transport_stream_attributes)<br />transport_stream_attributes.each do |attributes|<br />transport_streams.build(attributes)<br />end<br />end</p><p>def program_attributes=(program_attributes)<br />program_attributes.each do |attributes|<br />programs.build(attributes)<br />end<br />end<br />def stream_attributes=(stream_attributes)<br />stream_attributes.each do |attributes|<br />streams.build(attributes)<br />end<br />end</p><p>end<br />---------------------in views(new.html.erb)&lt;h1&gt;New containerformat&lt;/h1&gt;</p><p>&lt;% form_for(@containerformat) do |f| %&gt;<br />&nbsp; &lt;%= f.error_messages %&gt;</p><p>&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= f.label :stream_name %&gt;&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= f.text_field :stream_name %&gt;<br />&nbsp; &lt;/p&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= f.label :location %&gt;&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= f.text_field :location %&gt;<br />&nbsp; &lt;/p&gt;<br />&nbsp; &lt;p&gt;<br />&nbsp; &nbsp; &lt;%= f.label :containertype_id %&gt;&lt;br /&gt;<br />&nbsp; &nbsp; &lt;%= f.text_field :containertype_id %&gt;<br />&nbsp; &lt;/p&gt;<br />&nbsp; <br />&nbsp; &lt;%for transport_stream in @containerformat.transport_streams%&gt;<br />&nbsp; &nbsp; &nbsp;&lt;%fields_for &quot;containerformat[transport_stream_attributes][]&quot;, transport_stream do |ts_form|%&gt;<br />&nbsp; &nbsp; &nbsp;&lt;p&gt;Num_programs&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp;&lt;p&gt;&lt;%= ts_form.text_field :num_programs%&gt;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp;&lt;p&gt;Encryption std&lt;/p&gt; <br />&nbsp; &nbsp; &nbsp;&lt;p&gt;&lt;%= ts_form.text_field :encryption_std%&gt;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp;&lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp;&lt;% end %&gt;</p><p>&nbsp; <br />&nbsp; &nbsp; &lt;%for program in @containerformat.programs%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;%fields_for &quot;containerformat[program_attributes][]&quot;, program do |ts_form|%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;p&gt;PID&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;p&gt;&lt;%= ts_form.text_field :pid%&gt;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp;&lt;%for stream in @containerformat.streams%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;%fields_for &quot;containerformat[stream_attributes][]&quot;, stream do |ts_form|%&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;videocodecid&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;%= ts_form.text_field :videoCodec_id%&gt;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;audiocodecid&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;%= ts_form.text_field :audioCodec_id%&gt;&lt;/p&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;% end %&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;% end %&gt;<br />&nbsp; <br />&nbsp; <br />&nbsp; &lt;p&gt;<br />&nbsp; <br />&nbsp; &nbsp; &lt;%= f.submit &quot;Create&quot; %&gt;<br />&nbsp; &lt;/p&gt;<br />&lt;% end %&gt;</p><p>&lt;%= link_to &#039;Back&#039;, containerformats_path %&gt;<br />-------showpage<br />&lt;p&gt;<br />&nbsp; &lt;b&gt;Stream name:&lt;/b&gt;<br />&nbsp; &lt;%=h @containerformat.stream_name %&gt;<br />&lt;/p&gt;</p><p>&lt;p&gt;<br />&nbsp; &lt;b&gt;Location:&lt;/b&gt;<br />&nbsp; &lt;%=h @containerformat.location %&gt;<br />&lt;/p&gt;</p><p>&lt;p&gt;<br />&nbsp; &lt;b&gt;containertype_id:&lt;/b&gt;<br />&nbsp; &lt;%=h @containerformat.containertype_id %&gt;<br />&lt;/p&gt;</p><p>&lt;%- @containerformat.transport_streams.each do |task| -%&gt;<br />&lt;p&gt;<br />&nbsp; &nbsp; &lt;b&gt;Number of programs:&lt;/b&gt;<br />&nbsp; &nbsp; &lt;%= task.num_programs %&gt;<br />&lt;/p&gt;<br />&lt;%- end -%&gt;</p><p>&lt;%- @containerformat.programs.each do |task| -%&gt;<br />&lt;p&gt;<br />&nbsp; &nbsp; &lt;b&gt;PID:&lt;/b&gt;<br />&nbsp; &nbsp; &lt;%= task.pid %&gt;<br />&lt;/p&gt;<br />&lt;%- end -%&gt;</p><p>&lt;%- @containerformat.streams.each do |task| -%&gt;<br />&lt;p&gt;<br />&nbsp; &nbsp; &lt;b&gt;videoCodec_id:&lt;/b&gt;<br />&nbsp; &nbsp; &lt;%= task.videoCodec_id %&gt;<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; &lt;b&gt;audiocodecid:&lt;/b&gt;<br />&nbsp; &nbsp; &lt;%= task.audioCodec_id %&gt;<br />&nbsp; &nbsp; &lt;/p&gt;<br />&lt;%- end -%&gt;</p><p>&lt;%= link_to &#039;Edit&#039;, edit_containerformat_path(@containerformat) %&gt; |<br />&lt;%= link_to &#039;Back&#039;, containerformats_path %&gt;</p><p>Can you tell me where i am doing the mistake?<br />Can you suggest me how to get the valus of other tables in the show page?</p><p>regards<br />Srikanth</p>]]></description>
			<author><![CDATA[dummy@example.com (srikanth)]]></author>
			<pubDate>Fri, 20 Mar 2009 09:24:48 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=91121#p91121</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=91118#p91118</link>
			<description><![CDATA[<p>Hi!<br />1. Could you please respect some punctuation, because it is not esay to understand wher you stop and start a new sentence?<br />2. To suggest something I have you to reply for some questions</p><p>- do you work with an existing DD schema or you should create one yourself?<br />- you tell<br /></p><div class="quotebox"><blockquote><p>Each containerformat has many trasportstreams and each transportstream has many programs and each program may have more than one video and audio streams.details of audio and video streams are updated in stream table.</p></blockquote></div><p>In this case I&#039;d see you models like that<br /><pre name="code" class="ruby:nogutter">class containerformat &lt; AR<br />&nbsp; has_many :transportstreams<br />end<br />class transportstream &lt; AR<br />&nbsp; belongs_to:containerformat <br />&nbsp; has_many :programs<br />end</p><p>class program &lt; AR<br />&nbsp; belongs_to:transportstream <br />&nbsp; has_many :streams<br />end</pre><br />Then you tell as follows:<br /></p><div class="quotebox"><blockquote><p>I want to upload a stream called &#039;1.ts&#039; the stream has more programs and each program will have one or more video and audio streams and each audio and video details are stored in streams table.</p></blockquote></div><p>That&#039;s why I suppose that you have a work flow like that:</p><p>containerformat -&gt; has many -&gt; transportstreams -&gt; has many -&gt; programs -&gt; has many -&gt; streams.<br />If it&#039;s the case no need to use has_many :through association. Use it only if something has many &#039;through something&#039; like for example transportstream has many streams through programs. In this case you program table should have a reference as transportstream_id to the corresponding transportstream.</p>]]></description>
			<author><![CDATA[dummy@example.com (Javix)]]></author>
			<pubDate>Fri, 20 Mar 2009 08:18:39 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=91118#p91118</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=91106#p91106</link>
			<description><![CDATA[<p>Hi Javix ,<br />Thank you for the response.<br />As i am new to rails i dont have much idea on associations .<br />But i want to provide the association between models in my application while uploading the sterams.<br />ex:<br />I want to upload a stream called &#039;1.ts&#039; the stream has more programs and each program will have one or more video and audio streams and each audio and video details are stored in streams table.</p><p>this the data of stream to be uploaded in to database.</p><p>For this i have below tables :<br />containerformats:to store the name of stream and location<br />----------------</p><p>trasportstreams:has below fields<br />----------------<br />&quot;num_programs&quot;<br />&quot;encryption_std&quot;<br />&quot;containerformat_id&quot;</p><p>programs table: has below fields<br />----------------<br />&quot;pid&quot;<br />&quot;closedcaption&quot;<br />&quot;privatedata_pid&quot;<br />&quot;transport_stream_id&quot;<br />&quot;numAudio&quot;<br />&quot;numVideo&quot;</p><p>streams table:has below fields<br />-----------<br />&quot;videoCodec_id&quot;<br />&quot;resolution&quot;<br />&quot;audioSamplingRate&quot;</p><p>And i am using ryans complexforms post to upload data into models.</p><p>--Can you suggest me to provide the association between the models.<br />i could not able to proceede from this step.<br />Any help is greatly appreciated.</p><p>thanks<br />Srikanth</p>]]></description>
			<author><![CDATA[dummy@example.com (srikanth)]]></author>
			<pubDate>Fri, 20 Mar 2009 05:03:02 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=91106#p91106</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=91081#p91081</link>
			<description><![CDATA[<p>There is something wrong in your models. First you tell that your ContainerStream has many TransportStreams, and each TransportStream has many Programs. In you models you do as if ContainerStream has many TransportStreams, and Program has many TransportsStreams. Beside that you do in you model that TransportStream has many Programs. So it&#039;s difficult to understand where you&#039;d like to put many-to-many relation, - <br />1. Between ContainerFormat and Programs or <br />2. Between Programs and TransportStreams. <br />Check it one more time, please.<br />If the first solution is right, so you should add one more belongs_to rule to your TransportStream model</p>]]></description>
			<author><![CDATA[dummy@example.com (Javix)]]></author>
			<pubDate>Thu, 19 Mar 2009 21:05:32 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=91081#p91081</guid>
		</item>
		<item>
			<title><![CDATA[Re: Creating Two Models in One Form]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=91031#p91031</link>
			<description><![CDATA[<p>Anyone tried Rails 2.3.2 ability to do that?</p>]]></description>
			<author><![CDATA[dummy@example.com (Johnson)]]></author>
			<pubDate>Thu, 19 Mar 2009 16:31:10 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=91031#p91031</guid>
		</item>
	</channel>
</rss>
