This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/kaminari.rb | |
module Kaminari | |
module Helpers | |
class Paginator < Tag | |
def relevant_pages(options) | |
1..options[:total_pages] | |
end | |
class PageProxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/concerns/sluggable_model.rb | |
# | |
# https://gist.github.com/firedev/9701874 | |
# | |
# Usage: | |
# | |
# rails g migration addSlugToModel slug:string:uniq | |
# | |
# include SluggableModel | |
# attr_slug :title [, :slug] [, &block] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/environments/development.rb | |
require "net/smtp" # don't forget to add this first | |
# Try to sniff out if MockSMTP or MailCatcher is running | |
begin | |
smtp = Net::SMTP.start "localhost", 1025 | |
if smtp.started? | |
smtp.quit | |
puts ">> Emails WILL be sent to the SMTP server on port 1025" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ReadMarkable | |
extend ActiveSupport::Concern | |
included do | |
has_many :read_marks | |
def touch_read_at | |
update_column(:read_at, Time.now) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/concerns/metable_model.rb | |
# | |
# https://gist.github.com/firedev/644b41967cf6c1c9d035 | |
# | |
# Usage: | |
# | |
# rails g migration addMetaToModel meta:string | |
# | |
# include MetableModel | |
# metable [:meta] [, :body] [, &block] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# translit.rb | |
# | |
# https://gist.github.com/firedev/128521f9cc8d63eaff77 | |
# | |
# Converts russian strings to english translit | |
# | |
# Usage: | |
# | |
# Translit.(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Hides Draper decorator inside the model and lazily decorates resources | |
# | |
# https://gist.github.com/firedev/7a82059b30a2157d4c56 | |
# | |
# model.rb: | |
# include Decorated | |
# | |
# Just make sure there are no overlapping method names in ModelDecorator | |
module Decorated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# db/seeds.rb | |
# | |
# https://gist.github.com/firedev/5d9cd290da97d3c131e3 | |
# | |
# Imports records from .yml files in db/seed/model.yml | |
def put_cycle | |
@r ||= %w(- \\ | /) | |
print((@r << @r.shift)[0]) | |
print "\b" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# controllers/concerns/record_not_found.rb | |
# | |
# Redirects visitor up the restful route if record not found | |
# | |
# /articles/404 -> /articles/ -> / | |
module RecordNotFound | |
extend ActiveSupport::Concern | |
included do |
OlderNewer