Skip to content

Instantly share code, notes, and snippets.

View yamaaki's full-sized avatar

Yamaya Akihiro yamaaki

  • Tokyo, Japan
View GitHub Profile
#admin-members-form
= form_for [:admin, @member] do |f|
.row
.input-field.col.s12.l9
i.material-icons.prefix email
= f.email_field :email, class: 'validate'
= f.label :email
.row
#admin-members-new
- unless @member.errors.empty?
ul.hide
- @member.errors.full_messages.each do |msg|
li.u-toast = msg
.row
.col.s12.m9
.section
#p-title.col.s12.scrollspy
#admin-members-edit
- unless @member.errors.empty?
ul.hide
- @member.errors.full_messages.each do |msg|
li.u-toast = msg
.row
.col.s12.m9
.section
#p-title.col.s12.scrollspy
class MaterializeRenderer < SimpleNavigation::Renderer::Base
def render(item_container)
data = hash_render(item_container)
list = []
data.each do |item|
unless item[:items]
options = { class: "waves-effect waves-teal #{item[:class].present? ? item[:class] : ''}" }
options[:method] = item[:method] if item[:method]
a = link_to item[:name], item[:url], options
li = content_tag :li, a, class: (item[:selected] ? 'active' : '')
SimpleNavigation::Configuration.run do |navigation|
navigation.renderer = MaterializeRenderer
navigation.auto_highlight = false
navigation.items do |primary|
primary.item :book_header, '[Book]', '#' do |sub_nav|
sub_nav.item :books, 'Books', books_path, highlights_on: hl(:books)
sub_nav.item :new_book, 'New Book', new_book_path, highlights_on: hl(:new_book)
end
primary.item :welcome, 'Welcome', root_path, highlights_on: hl(:welcome)
module ApplicationHelper
ACTIVE = {
welcome: [ { welcome: %w(index ) } ],
new_book: [ { books: %w(new create ) } ],
books: [ { books: %w(index edit show update destroy) }, ],
}
def hl(key)
actives = ACTIVE[key] || []
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process :resize_to_limit => [500, 500]
en:
errors:
messages:
carrierwave_processing_error: failed to be processed
carrierwave_integrity_error: is not of an allowed file type
carrierwave_download_error: could not be downloaded
extension_white_list_error: "You are not allowed to upload %{extension} files, allowed types: %{allowed_types}"
extension_black_list_error: "You are not allowed to upload %{extension} files, prohibited types: %{prohibited_types}"
mime_type_pattern_white_list_error: "You are not allowed to upload %{content_type} files"
mime_type_pattern_black_list_error: "You are not allowed to upload %{content_type} files"
$(document).ready ->
if !$('.p-image-url').text() or $('.p-hidden-remove').val() is '1'
$('.p-image').attr('src', '').hide()
$('.p-icon').show()
$('.p-delete').hide()
$('.p-preview').click (e) ->
btn = $(@)
e and e.preventDefault()
require File.expand_path('../boot', __FILE__)
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
require 'action_controller/railtie'
require 'action_mailer/railtie'
require 'action_view/railtie'
require 'sprockets/railtie'