A somewhat complex action assembles two set of arrays into a single one.
@packages = (@packageoffers + @availables).sort_by(&:cost).paginate :page => params[:page], :per_page => 20
The view then renders a partial
@packages.each do |package|
if @packages_m.include?(package)
@mss = true
render partial: 'package', collection: @packages
elsif @availables.include?(package)
@mss = false
render partial: 'package', collection: @packages
else
end
Said partial then has two conditional block based on @mss (html code stripped):
number_to_currency(markup_price)
if @mss == true
package.typounit.stars
else
package.product_category
The error that occurs is occasional
ActionView::Template::Error (undefined method 'product_category' for #<Packageoffer:
Occasional, as the pagination has given a position via triangulation: pages where all results are from one array or the other render. The pages where the results are from both arrays generate the error.
While I can see the behaviour, I fail to comprehend why it functions when the collection comes from the same class.
And thus what is the solution? I see two possibilities:
• Can the partial call the sub array (@packageoffersor @availables)?
• is the boolean @mssa possible culprit?
• pagination can then become an issue as rails can lose track of which collection to count