Skip to content

Commit

Permalink
use string value for :scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
jdewyea committed Nov 22, 2010
1 parent 9bff563 commit 8b1fd44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions app/models/blog_comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ module Moderation
class << self
def enabled?
RefinerySetting.find_or_set(:comment_moderation, true, {
:scoping => :blog,
:scoping => 'blog',
:restricted => false
})
end

def toggle!
new_value = {
:value => !BlogComment::Moderation.enabled?,
:scoping => :blog,
:scoping => 'blog',
:restricted => false
}
if RefinerySetting.respond_to?(:set)
Expand All @@ -79,15 +79,15 @@ class << self
def recipients
RefinerySetting.find_or_set(:comment_notification_recipients, (Role[:refinery].users.first.email rescue ''),
{
:scoping => :blog,
:scoping => 'blog',
:restricted => false
})
end

def recipients=(emails)
new_value = {
:value => emails,
:scoping => :blog,
:scoping => 'blog',
:restricted => false
}
if RefinerySetting.respond_to?(:set)
Expand All @@ -99,15 +99,15 @@ def recipients=(emails)

def subject
RefinerySetting.find_or_set(:comment_notification_subject, "New inquiry from your website", {
:scoping => :blog,
:scoping => 'blog',
:restricted => false
})
end

def subject=(subject_line)
new_value = {
:value => subject_line,
:scoping => :blog,
:scoping => 'blog',
:restricted => false
}
if RefinerySetting.respond_to?(:set)
Expand Down
22 changes: 11 additions & 11 deletions app/models/blog_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class BlogPost < ActiveRecord::Base
validates_uniqueness_of :title

has_friendly_id :title, :use_slug => true

if Rails.version < '3.0.0'
named_scope :by_archive, lambda { |archive_date| {:conditions => ['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month], :order => "published_at DESC"} }
else
scope :by_archive, lambda { |archive_date|
where(['published_at between ? and ?', archive_date.beginning_of_month, archive_date.end_of_month]).order("published_at DESC")
}
end

if Rails.version < '3.0.0'
named_scope :all_previous, :conditions => ['published_at <= ?', Time.now.beginning_of_month], :order => "published_at DESC"
else
Expand All @@ -29,27 +29,27 @@ class BlogPost < ActiveRecord::Base
else
scope :live, lambda { where( "published_at < ? and draft = ?", Time.now, false).order("published_at DESC") }
end

if Rails.version < '3.0.0'
named_scope :previous, lambda { |i| { :conditions => ["published_at < ?", i.published_at], :order => "published_at DESC", :limit => 1 } }
named_scope :next, lambda { |i| { :condtions => ["published_at > ?", i.published_at], :order => "published_at ASC", :limit => 1 } }
else
scope :previous, lambda { |i| where(["published_at < ?", i.published_at]).order("published_at DESC").limit(1) }
scope :next, lambda { |i| where(["published_at > ?", i.published_at]).order("published_at ASC").limit(1) }
end

def next
self.class.next(self).first
end

def prev
self.class.previous(self).first
end

def live?
!draft and published_at <= Time.now
end

def category_ids=(ids)
self.categories = ids.reject{|id| id.blank?}.collect {|c_id|
BlogCategory.find(c_id.to_i) rescue nil
Expand All @@ -59,21 +59,21 @@ def category_ids=(ids)
class << self
def comments_allowed?
RefinerySetting.find_or_set(:comments_allowed, true, {
:scoping => :blog
:scoping => 'blog'
})
end
end

module ShareThis
DEFAULT_KEY = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

class << self
def key
RefinerySetting.find_or_set(:share_this_key, BlogPost::ShareThis::DEFAULT_KEY, {
:scoping => :blog
:scoping => 'blog'
})
end

def enabled?
key = BlogPost::ShareThis.key
key.present? and key != BlogPost::ShareThis::DEFAULT_KEY
Expand Down

0 comments on commit 8b1fd44

Please sign in to comment.