OK, I got it to work with this:

            response_id = request[:choices]
            Ramaze::Log.debug("Poll title = #{session[:today_poll].title}
choice = #{response_id}")
            r = Response[response_id]
            Ramaze::Log.debug("Current response = #{r.response} Current
count = #{r.count}")
            r[:count] = r[:count] + 1
            r.save
            Ramaze::Log.debug("Current response = #{r.response} Current
count = #{r.count}")


I'm still not sure why what I posted earlier didn't work. It seems like
they're pretty much equivalent.

Anyone who can enlighten me?

Scott

On Sat, Jul 4, 2009 at 10:41 AM, Scott LaBounty <[email protected]> wrote:

> Jeremy,
>
> Thanks, I'm getting closer. I can't seem to get the increment to work.
> Here's what I have (Ramaze)
>
>             response_id = request[:choices]
>             Ramaze::Log.debug("Current response =
> #{Response[response_id].response} Current count =
> #{Response[response_id].count}")
>             Response[response_id].count = Response[response_id].count + 1
>             Response[response_id].save_changes
>             Ramaze::Log.debug("Current response =
> #{Response[response_id].response} Current count =
> #{Response[response_id].count}")
>
> So I'm grabbing the response_id (this is from the radio button as you
> suggested). Then I print out the current count (here 0), try to increment
> it, save it, and print again. The problem is that it's still 0.
>
> Thoughts?
>
> Scott
>
>
> On Fri, Jul 3, 2009 at 11:59 AM, Jeremy Evans <[email protected]>wrote:
>
>>
>> On Jul 3, 10:57 am, Scott LaBounty <[email protected]> wrote:
>> > I'm messing around with a poll of the day site (another example for my
>> blog)
>> > and am running across an issue where I'm not sure the best way to solve
>> it.
>> > I have a Poll table that has a Title, Question, Date and each of these
>> can
>> > have many reponses. So I create the polls and then display one with
>> radio
>> > buttons for selecting. When the user makes a selection and "votes" I
>> want to
>> > add one to the response's count. I have the Poll and can loop through
>> its
>> > reponses and compare with the response I get back from the user but was
>> > wondering if there's an easier/better way to do it.
>> >
>> > If this isn't clear enough, let me know and I'll try to explain better.
>>
>> Have the radio button return the response's id, and just look up the
>> response directly (make sure that the response's poll_id matches as
>> well).  Here's some (probably too) simple code:
>>
>>  DB[:responses][:id=>params[:reponse_id], :poll_id=>params[:poll_id]]
>> = {:count=>:count+1}
>>
>> Jeremy
>> >>
>>
>
>
> --
> Scott
> http://steamcode.blogspot.com/
>



-- 
Scott
http://steamcode.blogspot.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to