Commit 68223ff6 by Hoang Phuc Do

Remove ActiveAdmin

parent a01f17cd
...@@ -44,10 +44,6 @@ gem 'kaminari', '~> 1.0', '>= 1.0.1' ...@@ -44,10 +44,6 @@ gem 'kaminari', '~> 1.0', '>= 1.0.1'
gem 'devise', '~> 4.3' gem 'devise', '~> 4.3'
# Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide. # Automatic Ruby code style checking tool. Aims to enforce the community-driven Ruby Style Guide.
gem 'rubocop', '~> 0.49.1' gem 'rubocop', '~> 0.49.1'
# The administration framework for Ruby on Rails.
gem 'activeadmin', '~> 1.0'
# CKEditor is a WYSIWYG editor to be used inside web pages
gem 'ckeditor', '~> 4.2', '>= 4.2.3'
# Use Capistrano for deployment # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development # gem 'capistrano-rails', group: :development
......
...@@ -24,20 +24,6 @@ GEM ...@@ -24,20 +24,6 @@ GEM
erubi (~> 1.4) erubi (~> 1.4)
rails-dom-testing (~> 2.0) rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3) rails-html-sanitizer (~> 1.0, >= 1.0.3)
activeadmin (1.0.0)
arbre (>= 1.1.1)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.7)
jquery-rails
jquery-ui-rails
kaminari (>= 0.15, < 2.0)
railties (>= 4.2, < 5.2)
ransack (~> 1.3)
sass-rails
sprockets (< 4.1)
activejob (5.1.1) activejob (5.1.1)
activesupport (= 5.1.1) activesupport (= 5.1.1)
globalid (>= 0.3.6) globalid (>= 0.3.6)
...@@ -54,8 +40,6 @@ GEM ...@@ -54,8 +40,6 @@ GEM
tzinfo (~> 1.1) tzinfo (~> 1.1)
addressable (2.5.1) addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2) public_suffix (~> 2.0, >= 2.0.2)
arbre (1.1.1)
activesupport (>= 3.0.0)
arel (8.0.0) arel (8.0.0)
ast (2.3.0) ast (2.3.0)
autoprefixer-rails (7.1.1) autoprefixer-rails (7.1.1)
...@@ -65,9 +49,6 @@ GEM ...@@ -65,9 +49,6 @@ GEM
bootstrap-sass (3.3.6) bootstrap-sass (3.3.6)
autoprefixer-rails (>= 5.2.1) autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4) sass (>= 3.3.4)
bourbon (4.3.4)
sass (~> 3.4)
thor (~> 0.19)
builder (3.2.3) builder (3.2.3)
byebug (9.0.6) byebug (9.0.6)
capybara (2.14.0) capybara (2.14.0)
...@@ -83,12 +64,6 @@ GEM ...@@ -83,12 +64,6 @@ GEM
mime-types (>= 1.16) mime-types (>= 1.16)
childprocess (0.7.0) childprocess (0.7.0)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
ckeditor (4.2.3)
cocaine
orm_adapter (~> 0.5.0)
climate_control (0.2.0)
cocaine (0.5.8)
climate_control (>= 0.0.3, < 1.0)
coffee-rails (4.2.2) coffee-rails (4.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0) railties (>= 4.0.0)
...@@ -108,29 +83,12 @@ GEM ...@@ -108,29 +83,12 @@ GEM
faker (1.6.6) faker (1.6.6)
i18n (~> 0.5) i18n (~> 0.5)
ffi (1.9.18) ffi (1.9.18)
formtastic (3.1.5)
actionpack (>= 3.2.13)
formtastic_i18n (0.6.0)
globalid (0.4.0) globalid (0.4.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
has_scope (0.7.1)
actionpack (>= 4.1, < 5.2)
activesupport (>= 4.1, < 5.2)
i18n (0.8.4) i18n (0.8.4)
inherited_resources (1.7.2)
actionpack (>= 3.2, < 5.2.x)
has_scope (~> 0.6)
railties (>= 3.2, < 5.2.x)
responders
jbuilder (2.7.0) jbuilder (2.7.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
multi_json (>= 1.2) multi_json (>= 1.2)
jquery-rails (4.3.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
kaminari (1.0.1) kaminari (1.0.1)
activesupport (>= 4.1.0) activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1) kaminari-actionview (= 1.0.1)
...@@ -167,8 +125,6 @@ GEM ...@@ -167,8 +125,6 @@ GEM
parallel (1.11.2) parallel (1.11.2)
parser (2.4.0.0) parser (2.4.0.0)
ast (~> 2.2) ast (~> 2.2)
polyamorous (1.3.1)
activerecord (>= 3.0)
powerpack (0.1.1) powerpack (0.1.1)
public_suffix (2.0.5) public_suffix (2.0.5)
puma (3.9.1) puma (3.9.1)
...@@ -201,12 +157,6 @@ GEM ...@@ -201,12 +157,6 @@ GEM
rainbow (2.2.2) rainbow (2.2.2)
rake rake
rake (12.0.0) rake (12.0.0)
ransack (1.8.2)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.3)
rb-fsevent (0.9.8) rb-fsevent (0.9.8)
rb-inotify (0.9.8) rb-inotify (0.9.8)
ffi (>= 0.5.0) ffi (>= 0.5.0)
...@@ -275,12 +225,10 @@ PLATFORMS ...@@ -275,12 +225,10 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
activeadmin (~> 1.0)
bootstrap-sass (~> 3.3.6) bootstrap-sass (~> 3.3.6)
byebug byebug
capybara (~> 2.13) capybara (~> 2.13)
carrierwave (~> 1.0) carrierwave (~> 1.0)
ckeditor (~> 4.2, >= 4.2.3)
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
devise (~> 4.3) devise (~> 4.3)
faker (~> 1.6, >= 1.6.3) faker (~> 1.6, >= 1.6.3)
......
ActiveAdmin.register Category do
menu priority: 3
filter :title
filter :description
end
ActiveAdmin.register_page 'Dashboard' do
menu priority: 1, label: proc{ I18n.t('active_admin.dashboard') }
content title: proc{ I18n.t('active_admin.dashboard') } do
div class: 'blank_slate_container', id: 'dashboard_default_message' do
span class: 'blank_slate' do
span I18n.t('active_admin.dashboard_welcome.welcome')
small I18n.t('active_admin.dashboard_welcome.call_to_action')
end
end
end # content
end
ActiveAdmin.register Product do
menu priority: 2
permit_params :title, :description, :sku, :price, :image_url, :remove_image_url, :category_id, :user_id
index do
selectable_column
column('ID', sortable: :id) { |product| link_to "##{product.id}", admin_product_path(product) }
column('Product title', sortable: :title) { |product| link_to "#{product.title}", admin_product_path(product) }
column('Price', sortable: :price) { |product| number_to_currency(product.price) }
column('Category', sortable: :category_id) { |product| auto_link product.category }
end
filter :title
# @url: https://github.com/activeadmin/activeadmin/issues/1360#issuecomment-5949803
filter :user, label: 'User email', collection: proc { User.pluck(:email, :id) }
show theme: 'hi' do
attributes_table do
row :title
row :sku
row(:description) { |product| raw(product.description) }
row(:price) { |product| number_to_currency(product.price) }
row :category
row :user
row :created_at
row :updated_at
end
end
sidebar 'Product thumbnail', only: :show, if: proc { product.image_url.present? } do
image_tag(get_product_thumbnail(product, 170, 204), style: 'width: 100%;')
end
form do |f|
f.semantic_errors
f.inputs 'Product Details' do
f.input :title
f.input :sku
f.input :description, as: :ckeditor
f.input :price
f.input :category
f.input :user, collection: User.pluck(:email, :id)
end
f.inputs 'Product image', multipart: true do
f.input :image_url, as: :file, hint: f.object.image_url.present? ? image_tag(f.object.image_url.url)
: content_tag(:span, 'Upload your product image')
f.input :image_url_cache, as: :hidden
f.input :remove_image_url, as: :boolean, label: 'Remove this image?' unless f.object.image_url.blank?
end
f.actions
end
end
ActiveAdmin.register User do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
show do
attributes_table do
row :email
row :super_admin
row :current_sign_in_at
row :sign_in_count
row :created_at
end
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs 'Admin Details' do
f.input :email
f.input :password
f.input :password_confirmation
f.input :super_admin, label: 'Is super admin?'
end
f.actions
end
end
#= require active_admin/base
#= require ckeditor/init
#= require admin/custom
$(document).ready(function(){
if ( $('.ckeditor.input').find('label').length ) {
$('.ckeditor.input').find('label').css('float','none');
}
});
// SASS variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;
// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";
// Overriding any non-variable SASS must be done after the fact.
// For example, to change the default status-tag color:
//
// .status_tag { background: #6090DB; }
.cke_editor_product_description {
margin-left: 20%!important;
}
\ No newline at end of file
...@@ -2,14 +2,6 @@ class ApplicationController < ActionController::Base ...@@ -2,14 +2,6 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
# rescue_from ActiveRecord::RecordNotFound, :with => :render_404 # rescue_from ActiveRecord::RecordNotFound, :with => :render_404
def authenticate_active_admin_user!
authenticate_user!
unless current_user.super_admin?
flash[:error] = 'Unauthorized access!'
redirect_to root_path
end
end
def render_404 def render_404
respond_to do |format| respond_to do |format|
format.html { render file: "#{Rails.root}/public/404", layout: false, status: :not_found } format.html { render file: "#{Rails.root}/public/404", layout: false, status: :not_found }
......
class ProductsController < ApplicationController class ProductsController < ApplicationController
before_action :authenticate_user!, only: [:new, :edit, :create, :update, :destroy] before_action :authenticate_user!, only: [:new, :edit, :create, :update, :destroy]
before_action :set_product, only: [:show] before_action :set_product, only: :show
before_action :user_can_edit_product, only: [:edit, :update, :destroy] before_action :user_can_edit_product, only: [:edit, :update, :destroy]
# GET /products/new # GET /products/new
...@@ -32,7 +32,7 @@ class ProductsController < ApplicationController ...@@ -32,7 +32,7 @@ class ProductsController < ApplicationController
if @product.destroy if @product.destroy
flash[:success] = "Product #{@product.title} deleted" flash[:success] = "Product #{@product.title} deleted"
else else
flash[:danger] = "Product #{@product.title} can't be deleted" flash[:alert] = "Product #{@product.title} can't be deleted"
end end
redirect_to root_url redirect_to root_url
...@@ -54,6 +54,6 @@ class ProductsController < ApplicationController ...@@ -54,6 +54,6 @@ class ProductsController < ApplicationController
# Is current user own current editing product? # Is current user own current editing product?
def user_can_edit_product def user_can_edit_product
@product = current_user.products.find_by(id: params[:id]) @product = current_user.products.find_by(id: params[:id])
redirect_to root_url, flash: { danger: 'You do not have permission to edit this product' } if @product.blank? redirect_to root_url, flash: { alert: 'You do not have permission to edit this product' } if @product.blank?
end end
end end
\ No newline at end of file
class Ckeditor::Asset < ActiveRecord::Base
include Ckeditor::Orm::ActiveRecord::AssetBase
delegate :url, :current_path, :content_type, to: :data
validates :data, presence: true
end
class Ckeditor::AttachmentFile < Ckeditor::Asset
mount_uploader :data, CkeditorAttachmentFileUploader, mount_on: :data_file_name
def url_thumb
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
end
end
class Ckeditor::Picture < Ckeditor::Asset
mount_uploader :data, CkeditorPictureUploader, mount_on: :data_file_name
def url_content
url(:content)
end
end
class Product < ApplicationRecord class Product < ApplicationRecord
attr_accessor :image_url_cache
belongs_to :category belongs_to :category
belongs_to :user belongs_to :user
mount_uploader :image_url, PictureUploader mount_uploader :image_url, PictureUploader
validates :category_id, presence: true validates :category_id, presence: true
validates :user_id, presence: true validates :user_id, presence: true
end end
\ No newline at end of file
# encoding: utf-8
require 'carrierwave'
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/ckeditor/attachments/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
Ckeditor.attachment_file_types
end
end
# encoding: utf-8
class CkeditorPictureUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
# Include RMagick or ImageScience support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
storage :file
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/ckeditor/pictures/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process scale: [200, 300]
#
# def scale(width, height)
# # do something
# end
process :extract_dimensions
# Create different versions of your uploaded files:
version :thumb do
process resize_to_fill: [118, 100]
end
version :content do
process resize_to_limit: [800, 800]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
Ckeditor.image_file_types
end
end
<p>Hello <%= @email %>!</p>
<% if @resource.try(:unconfirmed_email?) %>
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
<% else %>
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
<% end %>
<p>Hello <%= @resource.email %>!</p>
<p>We're contacting you to notify you that your password has been changed.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
ActiveAdmin.setup do |config|
# == Site Title
#
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
config.site_title = "DHP Ventura Shop"
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
#
# config.site_title_link = "/"
# Set an optional image to be displayed for the header
# instead of a string (overrides :site_title)
#
# Note: Aim for an image that's 21px high so it fits in the header.
#
# config.site_title_image = "logo.png"
# == Default Namespace
#
# Set the default namespace each administration resource
# will be added to.
#
# eg:
# config.default_namespace = :hello_world
#
# This will create resources in the HelloWorld module and
# will namespace routes to /hello_world/*
#
# To set no namespace by default, use:
# config.default_namespace = false
#
# Default:
# config.default_namespace = :admin
#
# You can customize the settings for each namespace by using
# a namespace block. For example, to change the site title
# within a namespace:
#
# config.namespace :admin do |admin|
# admin.site_title = "Custom Admin Title"
# end
#
# This will ONLY change the title for the admin section. Other
# namespaces will continue to use the main "site_title" configuration.
# == User Authentication
#
# Active Admin will automatically call an authentication
# method in a before filter of all controller actions to
# ensure that there is a currently logged in admin user.
#
# This setting changes the method which Active Admin calls
# within the application controller.
config.authentication_method = :authenticate_active_admin_user!
# == User Authorization
#
# Active Admin will automatically call an authorization
# method in a before filter of all controller actions to
# ensure that there is a user with proper rights. You can use
# CanCanAdapter or make your own. Please refer to documentation.
# config.authorization_adapter = ActiveAdmin::CanCanAdapter
# In case you prefer Pundit over other solutions you can here pass
# the name of default policy class. This policy will be used in every
# case when Pundit is unable to find suitable policy.
# config.pundit_default_policy = "MyDefaultPunditPolicy"
# You can customize your CanCan Ability class name here.
# config.cancan_ability_class = "Ability"
# You can specify a method to be called on unauthorized access.
# This is necessary in order to prevent a redirect loop which happens
# because, by default, user gets redirected to Dashboard. If user
# doesn't have access to Dashboard, he'll end up in a redirect loop.
# Method provided here should be defined in application_controller.rb.
# config.on_unauthorized_access = :access_denied
# == Current User
#
# Active Admin will associate actions with the current
# user performing them.
#
# This setting changes the method which Active Admin calls
# (within the application controller) to return the currently logged in user.
config.current_user_method = :current_user
# == Logging Out
#
# Active Admin displays a logout link on each screen. These
# settings configure the location and method used for the link.
#
# This setting changes the path where the link points to. If it's
# a string, the strings is used as the path. If it's a Symbol, we
# will call the method to return the path.
#
# Default:
config.logout_link_path = :destroy_user_session_path
# This setting changes the http method used when rendering the
# link. For example :get, :delete, :put, etc..
#
# Default:
config.logout_link_method = :delete
# == Root
#
# Set the action to call for the root path. You can set different
# roots for each namespace.
#
# Default:
# config.root_to = 'dashboard#index'
# == Admin Comments
#
# This allows your users to comment on any resource registered with Active Admin.
#
# You can completely disable comments:
# config.comments = false
#
# You can change the name under which comments are registered:
# config.comments_registration_name = 'AdminComment'
#
# You can change the order for the comments and you can change the column
# to be used for ordering:
# config.comments_order = 'created_at ASC'
#
# You can disable the menu item for the comments index page:
# config.comments_menu = false
#
# You can customize the comment menu:
# config.comments_menu = { parent: 'Admin', priority: 1 }
# == Batch Actions
#
# Enable and disable Batch Actions
#
config.batch_actions = true
# == Controller Filters
#
# You can add before, after and around filters to all of your
# Active Admin resources and pages from here.
#
# config.before_action :do_something_awesome
# == Localize Date/Time Format
#
# Set the localize format to display dates and times.
# To understand how to localize your app with I18n, read more at
# https://github.com/svenfuchs/i18n/blob/master/lib%2Fi18n%2Fbackend%2Fbase.rb#L52
#
config.localize_format = :long
# == Setting a Favicon
#
# config.favicon = 'favicon.ico'
# == Meta Tags
#
# Add additional meta tags to the head element of active admin pages.
#
# Add tags to all pages logged in users see:
# config.meta_tags = { author: 'My Company' }
# By default, sign up/sign in/recover password pages are excluded
# from showing up in search engine results by adding a robots meta
# tag. You can reset the hash of meta tags included in logged out
# pages:
# config.meta_tags_for_logged_out_pages = {}
# == Removing Breadcrumbs
#
# Breadcrumbs are enabled by default. You can customize them for individual
# resources or you can disable them globally from here.
#
# config.breadcrumb = false
# == Create Another Checkbox
#
# Create another checkbox is disabled by default. You can customize it for individual
# resources or you can enable them globally from here.
#
# config.create_another = true
# == Register Stylesheets & Javascripts
#
# We recommend using the built in Active Admin layout and loading
# up your own stylesheets / javascripts to customize the look
# and feel.
#
# To load a stylesheet:
# config.register_stylesheet 'my_stylesheet.css'
#
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
# config.register_stylesheet 'my_print_stylesheet.css', media: :print
#
# To load a javascript file:
# config.register_javascript 'my_javascript.js'
# == CSV options
#
# Set the CSV builder separator
# config.csv_options = { col_sep: ';' }
#
# Force the use of quotes
# config.csv_options = { force_quotes: true }
# == Menu System
#
# You can add a navigation menu to be used in your application, or configure a provided menu
#
# To change the default utility navigation to show a link to your website & a logout btn
#
# config.namespace :admin do |admin|
# admin.build_menu :utility_navigation do |menu|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
# admin.add_logout_button_to_menu menu
# end
# end
#
# If you wanted to add a static menu item to the default menu provided:
#
# config.namespace :admin do |admin|
# admin.build_menu :default do |menu|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
# end
# end
# == Download Links
#
# You can disable download links on resource listing pages,
# or customize the formats shown per namespace/globally
#
# To disable/customize for the :admin namespace:
#
# config.namespace :admin do |admin|
#
# # Disable the links entirely
# admin.download_links = false
#
# # Only show XML & PDF options
# admin.download_links = [:xml, :pdf]
#
# # Enable/disable the links based on block
# # (for example, with cancan)
# admin.download_links = proc { can?(:view_download_links) }
#
# end
# == Pagination
#
# Pagination is enabled by default for all resources.
# You can control the default per page count for all resources here.
#
# config.default_per_page = 30
#
# You can control the max per page count too.
#
# config.max_per_page = 10_000
# == Filters
#
# By default the index screen includes a "Filters" sidebar on the right
# hand side with a filter for each attribute of the registered model.
# You can enable or disable them for all resources here.
#
# config.filters = true
#
# By default the filters include associations in a select, which means
# that every record will be loaded for each association.
# You can enabled or disable the inclusion
# of those filters by default here.
#
# config.include_default_association_filters = true
# == Footer
#
# By default, the footer shows the current Active Admin version. You can
# override the content of the footer here.
#
# config.footer = 'my custom footer text'
# == Sorting
#
# By default ActiveAdmin::OrderClause is used for sorting logic
# You can inherit it with own class and inject it for all resources
#
# config.order_clause = MyOrderClause
end
# Use this hook to configure ckeditor
Ckeditor.setup do |config|
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'ckeditor/orm/active_record'
# Allowed image file types for upload.
# Set to nil or [] (empty array) for all file types
# By default: %w(jpg jpeg png gif tiff)
# config.image_file_types = %w(jpg jpeg png gif tiff)
# Allowed flash file types for upload.
# Set to nil or [] (empty array) for all file types
# By default: %w(jpg jpeg png gif tiff)
# config.flash_file_types = %w(swf)
# Allowed attachment file types for upload.
# Set to nil or [] (empty array) for all file types
# By default: %w(doc docx xls odt ods pdf rar zip tar tar.gz swf)
# config.attachment_file_types = %w(doc docx xls odt ods pdf rar zip tar tar.gz swf)
# Setup authorization to be run as a before filter
# By default: there is no authorization.
# config.authorize_with :cancan
# Override parent controller CKEditor inherits from
# By default: 'ApplicationController'
# config.parent_controller = 'MyController'
# Asset model classes
# config.picture_model { Ckeditor::Picture }
# config.attachment_file_model { Ckeditor::AttachmentFile }
# Paginate assets
# By default: 24
# config.default_per_page = 24
# Customize ckeditor assets path
# By default: nil
# config.asset_path = 'http://www.example.com/assets/ckeditor/'
# To reduce the asset precompilation time, you can limit plugins and/or languages to those you need:
# By default: nil (no limit)
# config.assets_languages = ['en', 'uk']
# config.assets_plugins = ['image', 'smiley']
# CKEditor CDN
# More info here http://cdn.ckeditor.com/
# By default: nil (CDN disabled)
# config.cdn_url = '//cdn.ckeditor.com/4.6.2/standard/ckeditor.js'
# JS config url
# Used when CKEditor CDN enabled
# By default: "ckeditor/config.js"
# config.js_config_url = 'ckeditor/config.js'
end
...@@ -4,6 +4,4 @@ Rails.application.routes.draw do ...@@ -4,6 +4,4 @@ Rails.application.routes.draw do
resources :categories resources :categories
resources :products resources :products
devise_for :users devise_for :users
ActiveAdmin.routes(self)
mount Ckeditor::Engine => '/ckeditor'
end end
class CreateActiveAdminComments < ActiveRecord::Migration::Current
def self.up
create_table :active_admin_comments do |t|
t.string :namespace
t.text :body
t.references :resource, polymorphic: true
t.references :author, polymorphic: true
t.timestamps
end
add_index :active_admin_comments, [:namespace]
end
def self.down
drop_table :active_admin_comments
end
end
class AddSuperAdminToUsers < ActiveRecord::Migration[5.1]
def change
add_column :users, :super_admin, :boolean, null: false, default: false
end
end
class CreateCkeditorAssets < ActiveRecord::Migration[5.1]
def self.up
create_table :ckeditor_assets do |t|
t.string :data_file_name, null: false
t.string :data_content_type
t.integer :data_file_size
t.string :type, limit: 30
# Uncomment it to save images dimensions, if your need it
t.integer :width
t.integer :height
t.timestamps null: false
end
add_index :ckeditor_assets, :type
end
def self.down
drop_table :ckeditor_assets
end
end
...@@ -10,37 +10,28 @@ ...@@ -10,37 +10,28 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170609152744) do ActiveRecord::Schema.define(version: 20170608073720) do
create_table "active_admin_comments", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "namespace"
t.text "body"
t.string "resource_type"
t.bigint "resource_id"
t.string "author_type"
t.bigint "author_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
end
create_table "categories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "categories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "title" t.string "title"
t.text "description" t.text "description"
end end
create_table "ckeditor_assets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "line_items", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "data_file_name", null: false t.integer "quantity", default: 1
t.string "data_content_type" t.bigint "product_id"
t.integer "data_file_size" t.bigint "order_id"
t.string "type", limit: 30 t.datetime "created_at", null: false
t.integer "width" t.datetime "updated_at", null: false
t.integer "height" t.index ["order_id"], name: "index_line_items_on_order_id"
t.index ["product_id"], name: "index_line_items_on_product_id"
end
create_table "orders", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.bigint "user_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.index ["type"], name: "index_ckeditor_assets_on_type" t.index ["user_id"], name: "index_orders_on_user_id"
end end
create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
...@@ -70,7 +61,9 @@ ActiveRecord::Schema.define(version: 20170609152744) do ...@@ -70,7 +61,9 @@ ActiveRecord::Schema.define(version: 20170609152744) do
t.string "last_sign_in_ip" t.string "last_sign_in_ip"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.boolean "super_admin", default: false, null: false t.string "username"
t.string "first_name"
t.string "last_name"
t.index ["email"], name: "index_users_on_email", unique: true t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment