English 中文(简体)
保存两个相同模型的积极记录,并在Rub铁路对由此产生的物体适用法
原标题:Concatenating two active records of same model and applying pagination for the resultant object in Ruby on Rails

试图进行过滤。 过滤意味着,当用户根据产品细节选择某些选择时,将展示。 如果用户选择妇女(部门)和男性部门,就应当展示所有属于妇女和男子的产品。 为此,我召集了两个目标。 该公司正在做罚款。 但是,当试图进行想象时,它就犯了一个错误:

A. 未经界定的“当前”方法

我想压缩两个积极记录物体,其结果只能作同样的积极记录。 请告诉我如何这样做。

现在,正在尝试的是:

@products += @prods

http://www.ohchr.org。

deptids=["1" "2"]
deptids.each do |did|
    @prods=ProductDetail.where("department_id=?",did)
    if !(@products.nil?)
        @products += @prods
    else
        @products=@prods
    end
end
最佳回答

Googling i在得知,问题正在想象之中,因为目前对Array的网页没有界定的方法。 因此,我用卡明里的原始阵列作假,我的问题是固定的。 Kaminari paginate range i refered 这一批量连接

我已经修改了我的法典。

def index
    count=ProductDetail.count
    deptids=["1" "2"]
    deptids.each do |did|
        @search_res=ProductDetail.search do
            with :department_id, did    
            paginate :page=>1, :per_page=>count
        end
    end
    if !(@products.nil?)
        unless @products.kind_of?(Array)
          @products = @products.page(params[:page]).per(30)
        else
          @products = Kaminari.paginate_array(@products).page(params[:page]).per(30)
        end
    end
end
问题回答

暂无回答




相关问题
Codeigniter WHERE on "AS" field

I have a query where I need to modify the selected data and I want to limit my results of that data. For instance: SELECT table_id, radians( 25 ) AS rad FROM test_table WHERE rad < 5 ORDER BY rad ...

Problem find joined table in rails

I have model represent association rule (Body => Head) def Item has_many :heads has_many :bodies ... end def Rule has_many :heads has_many :bodies ... end def Body belongs_to :item belongs_to :rule ...

FreeTDS Bad token from the server (SQL Server)

Today we had a lot more activity than normal between our Ruby on Rails application and our remote legacy SQL Server 2005 database, and we started getting the error below intermittently. What is is? ...

Castle ActiveRecord: one-to-one

While playing around with one-to-one associations in castle activerecord I stumbled upon the following problem: I m trying to model a one-to-one relationship (user-userprofile in this case). I ...

Sending email updates: model or observer?

I have an Event model, which stores an event feed for each user. I also need to email the updates to users which have enabled email notifications in their profile. From an architectural point of view,...

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

热门标签