Class: Gluttonberg::Public::ArticlesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Gluttonberg::Public::ArticlesController
- Defined in:
- app/controllers/gluttonberg/public/articles_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary (collapse)
Instance Method Details
- (Object) index
5 6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 5 def index @blog = Gluttonberg::Blog.published.first(:conditions => {:slug => params[:blog_id]}, :include => [:articles]) raise ActiveRecord::RecordNotFound.new if @blog.blank? @articles = @blog.articles.published respond_to do |format| format.html format.rss { render :layout => false } end end |
- (Object) preview
39 40 41 42 43 44 45 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 39 def preview @blog = Gluttonberg::Blog.first(:conditions => {:slug => params[:blog_id]}) raise ActiveRecord::RecordNotFound.new if @blog.blank? @article = Gluttonberg::Article.first(:conditions => {:slug => params[:article_id], :blog_id => @blog.id}) raise ActiveRecord::RecordNotFound.new if @article.blank? render :show end |
- (Object) show
16 17 18 19 20 21 22 23 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 16 def show @blog = Gluttonberg::Blog.published.first(:conditions => {:slug => params[:blog_id]}) raise ActiveRecord::RecordNotFound.new if @blog.blank? @article = Gluttonberg::Article.published.first(:conditions => {:slug => params[:id], :blog_id => @blog.id}) raise ActiveRecord::RecordNotFound.new if @article.blank? @comments = @article.comments.where(:approved => true) @comment = Comment.new(:subscribe_to_comments => true) end |
- (Object) tag
25 26 27 28 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 25 def tag @articles = Article.tagged_with(params[:tag]).includes(:blog).published @tags = Gluttonberg::Article.published.tag_counts_on(:tag) end |
- (Object) unsubscribe
30 31 32 33 34 35 36 37 |
# File 'app/controllers/gluttonberg/public/articles_controller.rb', line 30 def unsubscribe @subscription = CommentSubscription.find(:first , :conditions => {:reference_hash => params[:reference] }) unless @subscription.blank? @subscription.destroy flash[:notice] = "You are successfully unsubscribe from comments of \"#{@subscription.article.title}\"" redirect_to blog_article_url(@subscription.article.blog.slug, @subscription.article.slug) end end |