Ruby on Rails: Pagination with joins overwriting fields
I have three tables; stores, products and stocks. A stock has a product_id and a store_id (which reference a single row in the appropriate table). I found that using the scaffolded code however these connections are not automatically made. I needed to change the stock pagination code to include inner joins to the product and store tables. However, all three tables share some similar column names, like "name" for example. This meant that I was getting one value for name returned, instead of three. This makes sense, but isn't what I wanted.
I was initially going to use paginate_by_sql to solve this, but further reading let me to include two more parameters to my paginate call. I now have :select and :conditions set.
So, before you start including other code you might be able to solve your problem with existing methods.
The uncanny thing is that the other sites are also using stock and product tables in their examples!