Thanks for the response, sorry I'm totally new to this any way you can
elaborate or show example? Any help would be greatly appreciated,
thanks in advance
On Sep 25, 11:53 am, andres <[EMAIL PROTECTED]> wrote:
> On Thu, 2008-09-25 at 11:35 -0700, Dan Paul wrote:
> > Hello,
>
> > So I am trying to simply track the number of hits a link has received
> > and display that number on the site so other users can see which links
> > are more popular. So once the link is clicked on it adds a +1 value to
> > the hits column in the database and then redirects the person to the
> > url that the link is supposed to go to. So far this is what I have.
>
> > I have a tutorials table in my database and a column for hits and a
> > column for url.
>
> > ** tutorials_controller.rb **
>
> > def update_hits_count
> > [EMAIL PROTECTED] :hits, params[:count].size + 1
> > if @tutorial.save
> > redirect_to url_for(@tutorial.url)
> > end
> > end
>
> modify the method so it suits any controller,
> like in self.update_attribute
> add the method to application_controller
> whenever you want to add a hit you call it,
> like in
> def index
> update_hits_count
> end
>
>
>
>
>
> > ** view/tutorials/show.html.erb **
>
> > <% for tutorial in @tutorials %>
> > <%=link_to tutorial.title, {:action => 'update_hits_count', :count
> > => tutorial.hits} %>
> > <% end %>
>
> > That is what I have so far and when you click on the link the hits
> > column in the tutorials table just gets set to null and it does not
> > redirect them to the proper url. Any help would be greatly
> > appreciated. Thanks in advance.
>
> > >
> --
>
> smime.p7s
> 7KViewDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: 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/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---