small medium large xlarge

Generic-user-small
13 Jun 2012, 09:08
Burak AKIN (1 post)

Hello i am studying Agile web Developement. In the playtime area; i am trying to view sessions. i used this code in store controller

    def increment_counter
  if session[:counter].nil?
    session[:counter] = 0
  end
  session[:counter] += 1
end
  def index
    @count = increment_counter
    @products  = Product.all
    @time = Time.now
    @shown_message = "You've been here #{@count} times" if increment_counter >5
  end

and this one in the view

<h5><p><%= @shown_message %></p></h5>

. I can manage to see the counter after five times. But the count always increases by two (5,7,9,11).

Can you help me to solve this problem?

You must be logged in to comment