Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update tag_path to tagging_path

  • Loading branch information...
commit 322a985b664d00c889eb38b3cba53c837f7f4413 1 parent c19a187
@reyesyang authored
View
2  app/assets/stylesheets/global.scss
@@ -228,7 +228,7 @@ footer {
}
#cc_icon {
- margin: 0 0 -3px 0;
+ margin: -2px 0 0 0;
}
.code {
View
6 app/controllers/articles_controller.rb
@@ -71,6 +71,12 @@ def destroy
end
end
+ def tagging
+ tag = Tag.find_by_name! params[:tag]
+ @articles = tag.articles.includes(:tags).paginate(page: params[:page])
+ render :index
+ end
+
private
def load_article_with_tags
@article = Article.includes(:tags).find(params[:id])
View
25 app/controllers/tags_controller.rb
@@ -1,25 +0,0 @@
-class TagsController < ApplicationController
- before_filter :load_tag_by_name, only: [:show]
-
- def show
- @articles = @tag.articles.includes(:tags).paginate(page: params[:page])
- render 'articles/index'
- end
-
- def to_param
- name
- end
-
- def self.list(user)
- if user && user.admin?
- Tag.all
- else
- Tag.where("name != 'draft'").all
- end
- end
-
- private
- def load_tag_by_name
- @tag = Tag.find_by_name params[:id]
- end
-end
View
2  app/views/articles/_article.html.haml
@@ -9,7 +9,7 @@
%span.tags
= t 'tags'
- article.tags.each do |tag|
- = link_to tag_path(tag) do
+ = link_to tagging_path(tag) do
%span.label #{tag.name}
-if logged_in? && current_user.admin?
%span.operation
View
2  app/views/articles/show.html.haml
@@ -8,7 +8,7 @@
%span.tags
= t 'tags'
- @article.tags.each do |tag|
- = link_to tag_path(tag) do
+ = link_to tagging_path(tag) do
%span.label #{tag.name}
-if logged_in? && current_user.admin?
%span.operation
View
2  app/views/layouts/_aside.html.haml
@@ -18,7 +18,7 @@
%ul.unstyled
- @tags.each do |tag|
%li<
- = link_to tag_path(tag), :class=>'aside_tag' do
+ = link_to tagging_path(tag), :class=>'aside_tag' do
<span class='label'>#{tag.name}</span>
%span x #{tag.articles_count}
- else
View
4 config/routes.rb
@@ -2,10 +2,10 @@
Blog::Application.routes.draw do
root to: 'articles#index'
- post '/login', to: 'sessions#create'
+ post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
get "about" => "users#about"
resources :articles
- resources :tags, only: [:show]
+ get "/articles/tagging/:tag", to: "articles#tagging", as: :tagging
end
Please sign in to comment.
Something went wrong with that request. Please try again.