View helpers

Hi all,

I am trying to get my head around using view helpers.

My app has a Posters Model and I am allowing Users to vote on the best
poster using a Votes model. Posters are in three categories.

I want to build a filter to make sure people can only vote once in
each Poster Category.

The Vote entry has user_id (integer), poster_id(integer), category
(string)

On a simple level I want to start with a filter in my view file to
only display the 'Vote' link if an entry does not exist for the
current_user and relevant category.

I tried adding the following to my PostersHelper but kept getting
wrong number of arguments (0 for 1)

code below.

Any advice on this type of filter would be much appreciated.

Try this as code:

module PostersHelper
def already_voted_arts
Vote.exists?[‘user_id = ? AND category = ?’, current_user.id ,
“Arts”]
end
end

Mmm. I still get

wrong number of arguments (0 for 1)

Extracted source (around line #8):

5: <p>Due to the large number of entries we received voting has been
extended until 31 January 2010. Thank you to all of our <%=link_to
"sponsors", poster_sponsors_path%> for supporting our competition.</p>
6:
7: <h2>Arts and Humanities</h2>
8: <%if already_voted_arts%>
9: <p>You have already voted in this category</p>
10: <%else%>
11: <p><b><%=link_to "Place your Arts and Humanities vote now",
poster_arts_vote_path%></b></p>

def already_voted_arts
  !Vote.find_by_user_id_and_category(current_user.id, "Arts").blank?
end

Fantastic - that worked.

Thank you.

Dan