1
我正在學習實用的書架課。我嘗試製作一個會話計數器。 我的存儲控制器是Ruby on Rails session [:counter]增加兩個
class StoreController < ApplicationController
def increment_counter
if session[:counter].nil?
session[:counter] = 0
end
session[:counter] += 1
end
def index
@count = increment_counter
@products = Product.all
@cart = current_cart
@time = Time.now
@shown_message = "You've been here #{@count} times" if increment_counter >5
end
end
和我的看法是
<h5><p><%= @shown_message %></p></h5>..
,直到5倍這是行不通的。但是在它開始算作5,7,9,11之後。 。我的會話[:counter]有什麼問題?
謝謝Murifox ..This解決我的問題。 – ytsejam