Class: TagsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- TagsController
- Defined in:
- app/controllers/tags_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
#advertise, #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
#auto_complete_for_tag_name ⇒ Object
9 10 11 12 13 14 |
# File 'app/controllers/tags_controller.rb', line 9 def auto_complete_for_tag_name @tag_names = ActsAsTaggableOn::Tag.pluck(:name) respond_to do |format| format.json {render :inline => @tag_names.to_json} end end |
#cache_action? ⇒ Boolean
5 6 7 |
# File 'app/controllers/tags_controller.rb', line 5 def cache_action? !logged_in? && params[:type].blank? end |
#index ⇒ Object
16 17 18 |
# File 'app/controllers/tags_controller.rb', line 16 def index @tags = (100) end |
#show ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/tags_controller.rb', line 21 def show tag_array = ActsAsTaggableOn::DefaultParser.new( URI::decode(params[:id]) ).parse @tags = ActsAsTaggableOn::Tag.where('name IN (?)', tag_array ) if @tags.nil? || @tags.empty? flash[:notice] = :tag_does_not_exists.l_with_args(:tag => tag_array) redirect_to :action => :index and return end @related_tags = @tags.first. @tags_raw = @tags.collect { |t| t.name } .join(',') if params[:type] case params[:type] when 'Post', 'posts' @pages = @posts = Post.recent.tagged_with(tag_array).page(params[:page]).per(20) @photos, @users, @clippings = [], [], [] when 'Photo', 'photos' @pages = @photos = Photo.recent.tagged_with(tag_array).page(params[:page]).per(30) @posts, @users, @clippings = [], [], [] when 'User', 'users' @pages = @users = User.recent.tagged_with(tag_array).page(params[:page]).per(30) @posts, @photos, @clippings = [], [], [] when 'Clipping', 'clippings' @pages = @clippings = Clipping.recent.tagged_with(tag_array).page(params[:page]).per(10) @posts, @photos, @users = [], [], [] else @clippings, @posts, @photos, @users = [], [], [], [] end else @posts = Post.recent.limit(5).tagged_with(tag_array) @photos = Photo.recent.limit(10).tagged_with(tag_array) @users = User.recent.limit(10).tagged_with(tag_array) @clippings = Clipping.recent.limit(10).tagged_with(tag_array) end end |