Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Maechan maecha

🏠
Working from home
View GitHub Profile
@maecha
maecha / Gemfille
Last active Apr 3, 2018
Post a message to 'alert' channel in Slack
View Gemfille
gem 'json'
gem 'faye-websocket'
gem 'eventmachine'
gem 'slack-ruby-client'
@maecha
maecha / app|controllers|hoges_controller.rb
Last active Apr 3, 2018
Creating text-date, Convert Time Class to String Class
View app|controllers|hoges_controller.rb
class HogesController < ApplicationController
private
def get_date_text
from = params[:from]
to = params[:to]
wave_dash_text = ' ~ '
get_converted_string_date(from) + wave_dash_text + get_converted_string_date(to)
@maecha
maecha / app|controllers|concerns|bool_castable.rb
Created Apr 3, 2018
Create the module for to cast boolean
View app|controllers|concerns|bool_castable.rb
module Concerns
module BoolCastable
extend ActiveSupport::Concern
private
def cast_to_boolean(value)
ActiveRecord::Type::Boolean.new.cast(value)
end
end
@maecha
maecha / app|assets|javascripts|application.js
Created Apr 3, 2018
How to use TimePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
View app|assets|javascripts|application.js
:
:
//= require admin-lte/plugins/timepicker/bootstrap-timepicker.min
@maecha
maecha / app|assets|javascripts|application.js
Last active Apr 3, 2018
How to use DatePicker in AdminLTE ver2 (with Bootstrap 3.3.6)
View app|assets|javascripts|application.js
:
:
//= require admin-lte/plugins/datepicker/bootstrap-datepicker
//= require admin-lte/plugins/datepicker/locales/bootstrap-datepicker.ja
@maecha
maecha / Gemfile
Last active Apr 3, 2018
How to use 'Cocoon' | Ruby on Rails 5.1.4 | AdminLTE ver2 (with Bootstrap 3.3.6) | Model 'Hoge' and 'Model 'Fuga' are 'one-to-many relationship'
View Gemfile
gem 'cocoon'
gem 'jquery-rails'
@maecha
maecha / app|assets|javascripts|hoge.coffee
Last active Apr 2, 2018
How to make the disabled-link with CoffeeScript / for Ruby on Rails 5.1.4
View app|assets|javascripts|hoge.coffee
$(document).on 'turbolinks:load', ->
do ->
$('.disabled-link').click (e) ->
e.preventDefault()
return
@maecha
maecha / Gemfile
Last active Mar 31, 2018
Kaminari on 'Ruby on Rails 5.1.4'
View Gemfile
gem 'kaminari'
@maecha
maecha / app|views|hoges|new.html.slim
Last active Mar 29, 2018
Open modal view on AdminLTE ver2 (with Bootstrap 3.3.6)
View app|views|hoges|new.html.slim
/ the way it uses font awesome
= link_to '#', data: { toggle: 'modal', target: '#hoge-modal' } do
i.fa.fa-question-circle
end
== render partial: 'layouts/shared/modals/hoge'
@maecha
maecha / CLI
Last active Apr 6, 2018
Update select box when another one is updated. / E.g. Hoge and Fuga are 'one-to-many relationship', and use a controller 'Piyo' without this association .
View CLI
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
$ bundle exec rails -v
Rails 5.1.4