<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Refactoring the model with (:include)]]></title>
		<link>http://railsforum.com/viewtopic.php?id=53008</link>
		<description><![CDATA[The most recent posts in Refactoring the model with (:include).]]></description>
		<lastBuildDate>Thu, 28 Feb 2013 11:58:28 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Refactoring the model with (:include)]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=160743#p160743</link>
			<description><![CDATA[<p>I was in search of this information since many days, but unable to find the exact results for my problems. Could any one please produce some attachment links by providing the suggestions regarding my requirement? Thanks in advance.</p><br /><br /><br /><p><a href="http://www.kwiqrlink.com/">QR code generator</a><br /><a href="http://www.kwiqrlink.com/">QR codes</a></p>]]></description>
			<author><![CDATA[dummy@example.com (peeterminy)]]></author>
			<pubDate>Thu, 28 Feb 2013 11:58:28 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=160743#p160743</guid>
		</item>
		<item>
			<title><![CDATA[Refactoring the model with (:include)]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=159886#p159886</link>
			<description><![CDATA[<p>HI all </p><p>im still on learning curve about Rails and I need to refactor some models because the environment has a lower version basically this is not working properly (version 2.3.5 to 2.3.16)</p><div class="codebox"><pre><code> ReceivedItem.not_used.paginate(:include =&gt; [:mobile_gift_event, :mobile_item], :conditions =&gt; {:p1 =&gt; 5}, :page =&gt; params[:page],:per_page =&gt; 10)</code></pre></div><p>the error throwing&nbsp; table or view does not exist </p><p>but when I test this one <br /></p><div class="codebox"><pre><code>@receive_items = ReceivedItem.not_used.paginate( :conditions =&gt; {:p1 =&gt; current_user.usn.to_s}, :page =&gt; params[:page],:per_page =&gt; 10)</code></pre></div><p>this one getting a correct data </p><p>and this is the list of models </p><div class="codebox"><pre><code>Module Mobile
  class ReceivedItem &lt; Connector::Mobile
    set_table_name &quot;BATCH_MOBILE_DATA&quot;
    set_primary_key :exec_id
   
    belongs_to :mobile_gift_event, :class_name =&gt; &#039;Mobile::MobileGiftEvent&#039;,:foreign_key =&gt; :batch_id
    
    has_one :item, :class_name =&gt;&#039;Mobile::Item&#039;,:primary_key =&gt; :p2, :foreign_key =&gt; :itemno, :conditions =&gt; {:title_code =&gt; 1505}
  
    named_scope :not_used,:joins =&gt; :mobile_gift_event,:conditions =&gt; [&quot;BATCH_MOBILE_SUMMARY.view_yn = &#039;Y&#039; and BATCH_MOBILE_DATA.result_no = ? &quot;, DEFULT_RESULT ],:order =&gt; &quot;BATCH_MOBILE_DATA.REGDATE desc&quot;
  end
end</code></pre></div><div class="codebox"><pre><code>  module Mobile
    class MobileGiftEvent &lt; Connector::Mobile
      set_table_name &quot;BATCH_MOBILE_SUMMARY&quot;
      set_primary_key :batch_id

    end
  end</code></pre></div><div class="codebox"><pre><code>module Mobile
  class Item &lt; Connector::MobileGem
    set_table_name &quot;MOBILE_ITEM_INFO&quot;
    set_primary_key :itemno
    default_scope :conditions =&gt; {:title_code =&gt; 1505}

    has_one :mobile_bt_item

    named_scope :with_category, lambda {|cat| 
      {:conditions =&gt; [&quot;categoryno = ?&quot;, cat]}
    }
    
  end
end</code></pre></div><p>&nbsp; &nbsp; <br /></p><div class="codebox"><pre><code>module Mobile
  class BoxItem &lt; Connector::MobileGem
    set_table_name :mobile_box_item
    set_primary_key :mobile_box_item_code
  end
end</code></pre></div><p>&nbsp; &nbsp; </p><br /><p>how can i make this code into a better joining conditions </p><br /><div class="codebox"><pre><code> ReceivedItem.not_used.paginate(:include =&gt; [:mobile_gift_event, :mobile_item], :conditions =&gt; {:p1 =&gt; 5}, :page =&gt; params[:page],:per_page =&gt; 10)</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (jansky)]]></author>
			<pubDate>Fri, 15 Feb 2013 11:43:15 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=159886#p159886</guid>
		</item>
	</channel>
</rss>
