Hello folks.
I am building a site that let’s users track their progress on 30 day
challenges. To record their progress, users make a Post for each day
of the challenge. The Post object has a “complete” attribute to record
if they were successful on that particular day. When users view a
challenge, I build a UI element that both let’s users navigate to
daily Posts, and get a snapshot of the challenger’s progress. It
looks a little like this …
[10/11] [10/12] [10/13] … * 30 days, with different colored boxes
There are five types of buttons, with factors such as today’s date,
the presence of posts, the success of posts, etc.
- This day has a post, and the user was successful. This button is
GREEN, and has a link to view the post. - This day has a post, and the user was unsuccessful. This button is
RED, and has a link to view the post - This day is after today, so no posting is possible. This button is
GREY, and has NO link. - This day is post-able, but there is no post. This button is WHITE.
- This day is post-able, and the logged in user owns the challenge.
This button is YELLOW, and has a link to create a new post.
Tests with users have shown that this is one of their favorite parts
of the app, so it needs to stay.
I think I am approaching this incorrectly. Right now, I am building an
array of arrays in the controller … 1 item for each of the 30 days
in the nav. Each item is an array with data for the view …
. I pass this to the view using an
instance variable @thirtydays, and then use more logic on the View end
(e.g. “if boxtype == 3”) to decide how to display the button.
Something seems fishy about this to me but I am not skilled enough to
know why. What is the ‘correct’ way to supply data for UI elements
with lots of logic? Should I keep this all in the View? Should I
create a method under the Challenger class that takes a number (1-30),
and spits information for that particular day, and iterate from 1-30
in the View to create the buttons?
Thanks in advanced.
Confused Newbie
John