Class: CategoriesController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- CategoriesController
- Defined in:
- app/controllers/categories_controller.rb
Instance Method Summary collapse
-
#show ⇒ Object
GET /categories/1 GET /categories/1.xml.
- #show_tips ⇒ Object
Methods inherited from BaseController
#advertise, #cache_action?, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
Methods included from BaseHelper
#add_friend_link, #ajax_spinner_for, #avatar_for, #block_to_partial, #box, #city_cloud, #clippings_link, #commentable_url, #container_title, #excerpt_with_jump, #flash_class, #forum_page?, #is_current_user_and_featured?, #jumbotron, #last_active, #more_comments_links, #page_title, #paginating_links, #possesive, #profile_completeness, #render_jumbotron, #render_widgets, #rounded, #search_posts_title, #search_user_posts_path, #show_footer_content?, #tag_auto_complete_field, #time_ago_in_words, #time_ago_in_words_or_date, #topnav_tab, #truncate_words, #truncate_words_with_highlight, #widget
Methods included from LocalizedApplication
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
Methods included from AuthenticatedSystem
#login_by_token, #update_last_seen_at
Instance Method Details
#show ⇒ Object
GET /categories/1 GET /categories/1.xml
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/categories_controller.rb', line 7 def show @category = Category.find(params[:id]) order = (params[:popular] ? "view_count #{params[:popular].eql?('DESC') ? 'DESC' : 'ASC'}": "published_at DESC") @posts = Post.includes(:tags).where('category_id = ?', @category.id).order(order).page(params[:page]) @popular_posts = @category.posts.order("view_count DESC").limit(10) @popular_polls = Poll.find_popular_in_category(@category) @rss_title = "#{configatron.community_name}: #{@category.name} "+:posts.l @rss_url = category_path(@category, :format => :rss) @active_users = User.includes(:posts).where("posts.category_id = ? AND posts.published_at > ?", @category.id, 14.days.ago).references(:posts).limit(5).order("users.view_count DESC").to_a respond_to do |format| format.html # show.rhtml format.rss { render_rss_feed_for(@posts, {:feed => {:title => "#{configatron.community_name}: #{@category.name} "+:posts.l, :link => category_url(@category)}, :item => {:title => :title, :link => Proc.new {|post| user_post_url(post.user, post)}, :description => :post, :pub_date => :published_at} }) } end end |
#show_tips ⇒ Object
35 36 37 38 39 40 |
# File 'app/controllers/categories_controller.rb', line 35 def show_tips @category = Category.find(params[:id] ) render :partial => "/categories/tips", :locals => {:category => @category} rescue ActiveRecord::RecordNotFound render :partial => "/categories/tips", :locals => {:category => nil} end |