# Number of times clicked

**URL:** <https://www.ruby-forum.com/t/number-of-times-clicked/135134>\
**Category:** Rails\
**Created:** [April 18, 2008, 9:57am UTC](https://www.ruby-forum.com/t/number-of-times-clicked/135134 "2008-04-18T09:57:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 18, 2008, 9:57am UTC](https://www.ruby-forum.com/t/number-of-times-clicked/135134/1 "2008-04-18T09:57:42Z")

</div>

Hello, right now I have a boolean set up to trigger when a user clicks  
a link. Is there a way to give some feed back to user to return how  
many times separate booleans on a page have been clicked and keep  
track of this in a database.

For example a page may have ten booleans a user can trigger on and off  
(to undo). When the user clicks each one I want it to return the  
number of times each boolean has been triggered on. So if the user  
clicked the 7th one I want it to return 7 and if they undo one around  
like 4 I want 7 to update to 6. Is this possible? Does this make sense?

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 18, 2008, 10:01am UTC](https://www.ruby-forum.com/t/number-of-times-clicked/135134/2 "2008-04-18T10:01:23Z")

</div>

edberner wrote:

> Hello, right now I have a boolean set up to trigger when a user clicks  
> a link. Is there a way to give some feed back to user to return how  
> many times separate booleans on a page have been clicked and keep  
> track of this in a database.
> 
> For example a page may have ten booleans a user can trigger on and off  
> (to undo). When the user clicks each one I want it to return the  
> number of times each boolean has been triggered on. So if the user  
> clicked the 7th one I want it to return 7 and if they undo one around  
> like 4 I want 7 to update to 6. Is this possible? Does this make sense?

what are you trying to do?

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 18, 2008, 10:15am UTC](https://www.ruby-forum.com/t/number-of-times-clicked/135134/3 "2008-04-18T10:15:31Z")

</div>

> > For example a page may have ten booleans a user can trigger on and off  
> > (to undo). When the user clicks each one I want it to return the  
> > number of times each boolean has been triggered on. So if the user  
> > clicked the 7th one I want it to return 7 and if they undo one around  
> > like 4 I want 7 to update to 6. Is this possible? Does this make sense?

It’s possible. but i am not sure that it will make sense by decreasing  
amount of clicked if user undo boolean. Have you tried to code it?

Reinhart  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 18, 2008, 2:54pm UTC](https://www.ruby-forum.com/t/number-of-times-clicked/135134/4 "2008-04-18T14:54:19Z")

</div>

Ellis B. wrote:

> Yes but I ran into a roadblock. I set up habtm between actions and  
> teams and every time I added a hit I just would adjust the hit in the  
> team. But  
> As it turns out tree is a habtm between games and teams and it is all  
> getting very confusing very fast. I need something like team.sum  
> (action.hits)  
> All in all I I’m lost in how to implemnt this.

I am not too clear with your problem, if you have coded it, would you  
mind to show me? or email me to reinhart.showbiz ~[at]~ [live.com](http://live.com). if i  
am clear with your problem maybe i can help you to implement it. Please  
choose another example that i can understand clearly. But I clear your  
explain here:

> For example a page may have ten booleans a user can trigger on and off  
> (to undo). When the user clicks each one I want it to return the  
> number of times each boolean has been triggered on. So if the user  
> clicked the 7th one I want it to return 7 and if they undo one around  
> like 4 I want 7 to update to 6. Is this possible? Does this make sense?

simple code :

example the table OPTIONS has option boolean entities/columns that are  
A, B, C, D, E, F, G, H, I, J., the secenario is like this :

[1] User click D, controller will asl to Model to save “D” into table  
user example to column “clicked”. After it, Model option will be  
commanded too, so table OPTIONS in column D is updated for new amount of  
clicked.

[2] But User changes his mind to choose G now. Controller will commend  
User Model to update table User in column “clicked” to be G. Before  
change it, Model Options must be run first to update column G by  
increasing amount there and column D by decreasing amount there. How to  
get D (Previous choosen from user) is from find or read Table User  
first, before it will be updated to be G.

That;s it? or you have different thinking?

Reinhart  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)

---

<div class="post-metadata">

**Author:** ![edberner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f9ae1b/32.png) [@edberner](https://www.ruby-forum.com/u/edberner)\
**Post date:** [April 18, 2008, 2:08pm UTC](https://www.ruby-forum.com/t/number-of-times-clicked/135134/5 "2008-04-18T14:08:40Z")

</div>

Yes but I ran into a roadblock. I set up habtm between actions and  
teams and every time I added a hit I just would adjust the hit in the  
team. But  
As it turns out tree is a habtm between games and teams and it is all  
getting very confusing very fast. I need something like team.sum  
(action.hits)  
All in all I I’m lost in how to implemnt this.

On Apr 18, 2008, at 4:15 AM, Visit Indonesia 2008  
\<removed\_email\_address@domain.invalid
