This file contains hidden or 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
| # "Hello, %{name}!".interpolate(name: 'Tobias') # => "Hello, Tobias!" | |
| String::interpolate = (interpolations = {}) -> | |
| @replace /%\{(.*?)\}/g, (whole, key) -> | |
| camelizedKey = _(key).camelize() | |
| camelizedKey = camelizedKey.charAt(0).toLowerCase() + camelizedKey.slice(1) | |
| interpolations[camelizedKey] || interpolations[key] || '' |
This file contains hidden or 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
| String::camelize = -> | |
| pieces = @split(/[\W_-]/) | |
| $.map(pieces, (piece) -> piece.capitalize()).join("") | |
| String::capitalize = -> | |
| @charAt(0).toUpperCase() + @slice(1) | |
| String::dasherize = -> | |
| @replace("_", "-") | |
This file contains hidden or 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
| $.timeago.settings.strings = | |
| prefixAgo: I18n.translate('timeago.prefix_ago') # vor | |
| prefixFromNow: I18n.translate('timeago.prefix_from_now') # in | |
| suffixAgo: I18n.translate('timeago.suffix_ago') # "" | |
| suffixFromNow: I18n.translate('timeago.suffix_from_now') # "" | |
| seconds: (number) -> I18n.translate('timeago.seconds', seconds: number) # wenigen Sekunden | |
| minute: (number) -> I18n.translate('timeago.minute', minutes: number) # etwa einer Minute | |
| minutes: (number) -> I18n.translate('timeago.minutes', minutes: number) # %d Minuten | |
| hour: (number) -> I18n.translate('timeago.hour', hours: number) # etwa einer Stunde | |
| hours: (number) -> I18n.translate('timeago.hours', hours: number) # %d Stunden |
This file contains hidden or 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
| # Usage: | |
| # | |
| # include Sluggable | |
| # | |
| # slug :title | |
| # slug :title, to: :permalink | |
| # slug :title, unique: false | |
| # slug :title, force: true | |
| # slug :title, scope: [:category_id, :parent_id] | |
| # |
This file contains hidden or 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
| class ProductAttribute < ActiveRecord::Base | |
| # ... | |
| serialize :value | |
| class << self | |
| def with_value(value) | |
| dumped_value = serialized_attributes['value'].dump(value) | |
| where(value: dumped_value) | |
| end |
This file contains hidden or 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
| class HamlPresenter < Presenter | |
| include Haml::Helpers | |
| def initialize(locals = {}) | |
| super | |
| init_haml_helpers | |
| end | |
| end |
This file contains hidden or 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
| class FlagCollectionProxy | |
| attr_reader :record, :attribute_name | |
| def initialize(record, attribute_name) | |
| @record = record | |
| @attribute_name = attribute_name | |
| @flags = flag_converter.to_a(value).map(&:to_s) | |
| end | |
| def initialize_clone(other) |
This file contains hidden or 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
| createArbitraryField = ($button) -> | |
| $form = $button.closest('form') | |
| buttonName = $button.attr('name') | |
| buttonValue = $button.val() | |
| $('<input />', type: 'hidden', name: buttonName, value: buttonValue).appendTo($form) | |
| destroyArbitraryField = ($button) -> | |
| $form = $button.closest('form') | |
| buttonName = $button.attr('name') | |
| $form.find("input[type='hidden'][name='#{buttonName}']").remove() |
This file contains hidden or 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
| class ApplicationController < ActionController::Base | |
| include BreadcrumbedController | |
| before_action :set_controller_context | |
| private | |
| def set_controller_context | |
| RequestStore.store[:controller_context] = self | |
| end | |
| end |