Topic: Refactoring the model with (:include)
HI all
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)
ReceivedItem.not_used.paginate(:include => [:mobile_gift_event, :mobile_item], :conditions => {:p1 => 5}, :page => params[:page],:per_page => 10)the error throwing table or view does not exist
but when I test this one
@receive_items = ReceivedItem.not_used.paginate( :conditions => {:p1 => current_user.usn.to_s}, :page => params[:page],:per_page => 10)this one getting a correct data
and this is the list of models
Module Mobile
class ReceivedItem < Connector::Mobile
set_table_name "BATCH_MOBILE_DATA"
set_primary_key :exec_id
belongs_to :mobile_gift_event, :class_name => 'Mobile::MobileGiftEvent',:foreign_key => :batch_id
has_one :item, :class_name =>'Mobile::Item',:primary_key => :p2, :foreign_key => :itemno, :conditions => {:title_code => 1505}
named_scope :not_used,:joins => :mobile_gift_event,:conditions => ["BATCH_MOBILE_SUMMARY.view_yn = 'Y' and BATCH_MOBILE_DATA.result_no = ? ", DEFULT_RESULT ],:order => "BATCH_MOBILE_DATA.REGDATE desc"
end
end module Mobile
class MobileGiftEvent < Connector::Mobile
set_table_name "BATCH_MOBILE_SUMMARY"
set_primary_key :batch_id
end
endmodule Mobile
class Item < Connector::MobileGem
set_table_name "MOBILE_ITEM_INFO"
set_primary_key :itemno
default_scope :conditions => {:title_code => 1505}
has_one :mobile_bt_item
named_scope :with_category, lambda {|cat|
{:conditions => ["categoryno = ?", cat]}
}
end
end
module Mobile
class BoxItem < Connector::MobileGem
set_table_name :mobile_box_item
set_primary_key :mobile_box_item_code
end
end
how can i make this code into a better joining conditions
ReceivedItem.not_used.paginate(:include => [:mobile_gift_event, :mobile_item], :conditions => {:p1 => 5}, :page => params[:page],:per_page => 10)