scaffolds a tag list to mark tags as featured on the admin section
This commit is contained in:
22
app/controllers/admin/tags_controller.rb
Normal file
22
app/controllers/admin/tags_controller.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class Admin::TagsController < Admin::BaseController
|
||||
layout 'admin'
|
||||
|
||||
respond_to :html, :js
|
||||
|
||||
def index
|
||||
@tags = ActsAsTaggableOn::Tag.order(featured: :desc)
|
||||
end
|
||||
|
||||
def update
|
||||
@tag = ActsAsTaggableOn::Tag.find(params[:id])
|
||||
@tag.update(tag_params)
|
||||
redirect_to admin_tags_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def tag_params
|
||||
params.require(:tag).permit(:featured)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,3 +1,3 @@
|
||||
<div id="admin_menu">
|
||||
Admin links
|
||||
</div>
|
||||
<%= link_to t('admin.tags.index.title'), admin_tags_path %>
|
||||
</div>
|
||||
|
||||
18
app/views/admin/tags/index.html.erb
Normal file
18
app/views/admin/tags/index.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="left">
|
||||
<h1><%= t("admin.tags.index.title") %></h1>
|
||||
|
||||
<ul>
|
||||
<% @tags.each do |tag| %>
|
||||
<li>
|
||||
<strong><%= tag.name %></strong>
|
||||
|
||||
<%= form_for(tag, url: admin_tag_path(tag), as: :tag) do |f| %>
|
||||
<!-- <%= f.check_box :featured %> -->
|
||||
<%= f.check_box :featured, label: false %>
|
||||
<%= t("admin.tags.index.mark_as_featured") %>
|
||||
<%= f.submit(class: "button radius tiny") %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -78,6 +78,8 @@ en:
|
||||
comment_button: Publish comment
|
||||
reply_link: Reply
|
||||
reply_button: Publish reply
|
||||
tags:
|
||||
featured: Featured
|
||||
votes:
|
||||
agree: I agree
|
||||
disagree: I disagree
|
||||
@@ -117,3 +119,8 @@ en:
|
||||
default: "You are not authorized to access this page."
|
||||
manage:
|
||||
all: "You are not authorized to %{action} %{subject}."
|
||||
admin:
|
||||
tags:
|
||||
index:
|
||||
title: 'Debate topics'
|
||||
mark_as_featured: 'Mark as featured'
|
||||
|
||||
@@ -78,6 +78,8 @@ es:
|
||||
comment_button: Publicar comentario
|
||||
reply_link: Responder
|
||||
reply_button: Publicar respuesta
|
||||
tags:
|
||||
featured: Destacado
|
||||
votes:
|
||||
agree: Estoy de acuerdo
|
||||
disagree: No estoy de acuerdo
|
||||
@@ -129,3 +131,8 @@ es:
|
||||
all: "No tienes permiso para borrar %{subject}"
|
||||
manage:
|
||||
all: "No tienes permiso para realizar la acción '%{action}' sobre %{subject}."
|
||||
admin:
|
||||
tags:
|
||||
index:
|
||||
title: 'Temas de debate'
|
||||
mark_as_featured: 'Marcar como destacado'
|
||||
|
||||
@@ -23,6 +23,8 @@ Rails.application.routes.draw do
|
||||
|
||||
namespace :admin do
|
||||
root to: "dashboard#index"
|
||||
|
||||
resources :tags, only: [:index, :update]
|
||||
end
|
||||
|
||||
namespace :moderation do
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150811161459) do
|
||||
ActiveRecord::Schema.define(version: 20150815154430) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -79,6 +79,7 @@ ActiveRecord::Schema.define(version: 20150811161459) do
|
||||
create_table "tags", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.integer "taggings_count", default: 0
|
||||
t.boolean "featured", default: false
|
||||
end
|
||||
|
||||
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
|
||||
|
||||
Reference in New Issue
Block a user