Hi all,
Best wishes for the new year! :’)
I’m very new to Ruby and Rails, and I ran into a problem with the
“paginate” function. When I use the following method to get a number
of forum topics based on a category name passed via the URI:
@topic_pages, @topics = paginate :topics,
:joins => "INNER JOIN categories ON
topics.category_id = categories.id",
:conditions => [“topics.is_deleted !=
1 AND categories.safe_name = ?”, params[:category_name]],
:order_by => “topics.is_sticky DESC,
topics.id DESC”,
:per_page => 20
Then, on my topics listing page I try this:
for topic in @topics
link_to h(topic.title), :action => 'show', :id => topic
end
This comes up with a number of links that all have the same ID! Not
the ID of the topic, but it takes the ID from the category table. I’m
really baffled as to why it does this, as I’m not specifying
topic.category_id or anything like that.
Any ideas would be very welcome, indeed.
All the best,
Peter D.