ea8e9901f4
Your branch is behind 'origin/strong-params' by 1 commit, and can be fast-forwarded. I'll pull to catch up after this commit Change code to whitelist params Remove attr_accessible lines Add strong_params to Gemfile, since this branch is still on Rails 3 Mixin to ActiveRecord::Base ActiveModel::ForbiddenAttributesProtection Use an initializer for the mixin
18 lines
375 B
Ruby
18 lines
375 B
Ruby
class Analytics < ActiveRecord::Base
|
|
scope :hits_by_ip, ->(ip,col="*") { select("#{col}").where(:ip_address => ip).order("id DESC")}
|
|
|
|
def self.count_by_col(col)
|
|
calculate(:count, col)
|
|
end
|
|
|
|
def self.parse_field(field)
|
|
valid_fields = ["ip_address", "referrer", "user_agent"]
|
|
|
|
if valid_fields.include?(field)
|
|
field
|
|
else
|
|
"1"
|
|
end
|
|
end
|
|
end
|