Set the current locale.
Default is 'en'
.
$.li18n.currentLocale = 'de';
module ActiveAdminRemoteDestroyable | |
def self.included(dsl) | |
dsl.controller do | |
def destroy | |
destroy! do |format| | |
format.html | |
format.js {render js: %Q|$("tr##{resource.class.model_name.singular}_#{resource.id}").fadeOut();|} | |
end | |
end | |
end |
-# Expects: resource | |
= form_for resource, remote: true, validate: true, html: { class: "lab_test edit_#{resource.label}" } do |f| | |
= resource_form_header(resource) | |
- teaser = t("tests.#{resource.label}_resource.new_record_description") | |
- if resource.new_record? && teaser.exclude?('New Record') | |
%p= teaser | |
= render partial: 'generic_data/control_buttons', locals: { resource: resource } |
module WizardConcern | |
extend ActiveSupport::Concern | |
included do | |
has_many :step_statuses, dependent: :destroy | |
has_many :steps_completed, through: :step_statuses, source: :step, class_name: 'Step' | |
has_many :wizard_progresses, dependent: :destroy | |
delegate :wizards, to: :organization |
min = _.max(chartData.datasets[0].data) | |
max = _.min(chartData.datasets[0].data) | |
if max == min | |
opt = { | |
scaleOverride : true, | |
scaleSteps : 3, | |
scaleStepWidth : 1, | |
scaleStartValue : max - 2 | |
} |
def dice_rand | |
(1..10).inject(10) {|s,i| s + rand(6)} | |
end | |
def count_dice_avg(number) | |
res = Hash.new(0) | |
number.times { x = dice_rand; res[x] += 1} | |
res.sort_by {|k,v| v}.reverse | |
end |
namespace :paperclip_migration do | |
desc "migrate files from file storage to s3" | |
task :migrate_to_s3 => :environment do | |
puts "Migrating... carrierwave..." | |
Asset1.find_each do |record| | |
path = record.avatar.path.to_s | |
if path != record.avatar.default_url | |
file_path = (Rails.root.join('public', path) | |
if File.exists?(file_path) | |
file = File.open(file_path) |
Write a migration and ActiveRecord model that tracks restaurant reservations. Assume there is a table in your relational database named "reservations". Reservations have a start time, an end time and a table number. | |
Write some ActiveRecord validations that check new reservations for overbooking of the same table in the restaurant. For example, table #10 cannot have 2 reservations for the same period of time. This validation(s) should check time overlap for both record creation and updates. | |
Unit tests are a must to make sure your double booking validations are working. (rspec and unittests) |
brew list -1 | while read line; do brew unlink $line; brew link $line; done |