aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/refinery/blog/categorization.rb1
-rw-r--r--app/models/refinery/blog/category.rb9
-rw-r--r--app/models/refinery/blog/comment.rb2
-rw-r--r--app/models/refinery/blog/post.rb23
4 files changed, 6 insertions, 29 deletions
diff --git a/app/models/refinery/blog/categorization.rb b/app/models/refinery/blog/categorization.rb
index 7ca9c77..b7dbcc8 100644
--- a/app/models/refinery/blog/categorization.rb
+++ b/app/models/refinery/blog/categorization.rb
@@ -6,7 +6,6 @@ module Refinery
belongs_to :blog_post, :class_name => 'Refinery::Blog::Post', :foreign_key => :blog_post_id
belongs_to :blog_category, :class_name => 'Refinery::Blog::Category', :foreign_key => :blog_category_id
- attr_accessible :blog_category_id, :blog_post_id
end
end
end
diff --git a/app/models/refinery/blog/category.rb b/app/models/refinery/blog/category.rb
index acab8bf..5cf4ea5 100644
--- a/app/models/refinery/blog/category.rb
+++ b/app/models/refinery/blog/category.rb
@@ -1,10 +1,10 @@
module Refinery
module Blog
class Category < ActiveRecord::Base
+ extend FriendlyId
translates :title, :slug
- extend FriendlyId
friendly_id :title, :use => [:slugged, :globalize]
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_category_id
@@ -12,13 +12,6 @@ module Refinery
validates :title, :presence => true, :uniqueness => true
- attr_accessible :title
- attr_accessor :locale
-
- class Translation
- attr_accessible :locale
- end
-
def self.translated
with_translations(::Globalize.locale)
end
diff --git a/app/models/refinery/blog/comment.rb b/app/models/refinery/blog/comment.rb
index ae35a59..be94238 100644
--- a/app/models/refinery/blog/comment.rb
+++ b/app/models/refinery/blog/comment.rb
@@ -2,8 +2,6 @@ module Refinery
module Blog
class Comment < ActiveRecord::Base
- attr_accessible :name, :email, :message
-
filters_spam author_field: :name, email_field: :email, message_field: :body
belongs_to :post, foreign_key: 'blog_post_id'
diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb
index 1c2cf04..005ec29 100644
--- a/app/models/refinery/blog/post.rb
+++ b/app/models/refinery/blog/post.rb
@@ -4,51 +4,38 @@ require 'seo_meta'
module Refinery
module Blog
class Post < ActiveRecord::Base
+ extend FriendlyId
translates :title, :body, :custom_url, :custom_teaser, :slug, :include => :seo_meta
- extend FriendlyId
friendly_id :friendly_id_source, :use => [:slugged, :globalize]
- is_seo_meta if self.table_exists?
-
- belongs_to :author, proc{ readonly(true) }, :class_name => Refinery::Blog.user_class.to_s, :foreign_key => :user_id
+ is_seo_meta
- has_many :comments, :dependent => :destroy, :foreign_key => :blog_post_id
acts_as_taggable
+ belongs_to :author, proc { readonly(true) }, :class_name => Refinery::Blog.user_class.to_s, :foreign_key => :user_id
+ has_many :comments, :dependent => :destroy, :foreign_key => :blog_post_id
has_many :categorizations, :dependent => :destroy, :foreign_key => :blog_post_id
has_many :categories, :through => :categorizations, :source => :blog_category
validates :title, :presence => true, :uniqueness => true
validates :body, :presence => true
validates :published_at, :author, :presence => true
-
validates :source_url, :url => { :if => 'Refinery::Blog.validate_source_url',
:update => true,
:allow_nil => true,
:allow_blank => true,
:verify => [:resolve_redirects]}
- attr_accessible :title, :body, :custom_teaser, :tag_list, :draft, :published_at, :custom_url, :author
- attr_accessible :browser_title, :meta_description, :user_id, :category_ids
- attr_accessible :source_url, :source_url_title
- attr_accessor :locale
-
class Translation
is_seo_meta
- attr_accessible :browser_title, :meta_description, :locale
end
- # Delegate SEO Attributes to globalize3 translation
+ # Delegate SEO Attributes to globalize translation
seo_fields = ::SeoMeta.attributes.keys.map{|a| [a, :"#{a}="]}.flatten
delegate(*(seo_fields << {:to => :translation}))
- before_save do |m|
- m.translation.globalized_model = self
- m.translation.save if m.translation.new_record?
- end
-
self.per_page = Refinery::Blog.posts_per_page
def next