Goal:
- Label certain “items” in the database as “featured.”
- View the “featured items” on a list page
- On the list page, each “featured item” links to a item show page.
- On each “featured item” show page, there are links to show the
previous or next “featured item” - The show “previous featured item” and show “next featured item”
links should be automagicly generated in the layout.
There are probably a number of ways to accomplish this, but my big
n00b is getting in the way.
First Guess: Pagination Module
My first guess was that I could use something within the Pagination
module, but so far Pagination appears to be limited to taking all the
“items” in the database, and showing them in order by id in sets of a
X number of items.
I don’t see a pagination option for labeling certain items as
“featured” and then listing only those items, nor a way of placing
links in the view so as to store the position within the “featured
item list” as the browser moves from “featured item” page to “featured
item” page.
Second Guess: Acts_as_Taggable Plugin
Second, I tried using the act_as_taggable plugin (not gem) and then
the act_as_taggable_on_steroids plugin. This pretty much fell apart
from the start since I spent most of the day hunting down missing
setup instructions.
The wiki HowTo says one thing, the on_steroids site says another.
Neither seems to include all the information necessary to set the
plugin up. I tried following the “Rails Recipes” book (The Pragmatic
Programmer has a free PDF download of Chapter 19) but it is
embellished with trips to the “ruby script/console”, layered partials,
and ajax – all of which really confused me.
If I go this route, it seems like I need a join table, but not a
table1_table2 join table, but instead a special join table named
“taggings”.
Anyway, I am starting to whine more than ask for help, so … help …
anyone?
My best guess at this point is:
- Create a tags table with an “id” field as primary key and “name”
field - Create a tag named “featured”
- ?? Use a join table between tags_items to tag specific “items” as
“featured” - ?? Controller: Some how assemble an array of only the “featured
items” - ?? View: Index page renders each featured_item in @featured_items
- ?? View: Item page somehow set the previous/next links to
current_array_item ±1 - Weep for joy that someone helped me get it to work.