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
$ irb | |
irb(main):001:0> require 'alchemist' | |
=> true | |
irb(main):002:0> Alchemist.setup | |
=> [:absorbed_radiation_dose, :angles, :area, :capacitance, :distance, :dose_equivalent, :electric_charge, :electric_conductance, :electrical_impedance, :electromotive_force, :energy, :frequency, :force, :illuminance, :inductance, :information_storage, :luminous_flux, :luminous_intensity, :magnetic_flux, :magnetic_inductance, :mass, :power, :pressure, :radioactivity, :time, :volume, :density, :temperature] | |
irb(main):003:0> 1.kb.to.b | |
=> 999.9999999999999 | |
irb(main):004:0> 1.b.to.kb | |
=> 1.0 | |
irb(main):005:0> 1.b.to.mb |
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
ActiveRecord::Schema.define(version: 20131006225214) do | |
create_table "matches", force: true do |t| | |
t.integer "result" | |
t.boolean "checked_out", default: false | |
t.boolean "repeated", default: false | |
t.boolean "planned", default: true | |
t.integer "round" | |
t.datetime "created_at" | |
t.datetime "updated_at" |
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
def create | |
@user = User.find(params[:user_id]) | |
@stock = Stock.find_or_create_by_ticker(params[:ticker]) | |
@user.stocks << @stock | |
respond_with @stock | |
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
$(document).on 'ajax:success', '#contact_details a', (xhr, data) -> | |
$('#contact_details').html(data.details) | |
setupJobTagger = -> | |
$('#job_tag_list').select2 | |
tags: [] | |
ajax: | |
url: $('#job_tag_list').data('url') | |
dataType: 'json', | |
results: (data, page) -> |
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
$ gem install activeadmin | |
ERROR: While executing gem ... (Gem::ImpossibleDependenciesError) | |
arbre-1.0.1 requires activesupport (>= 3.0.0) but it conflicted: | |
Activated activesupport-4.0.0 instead of (= 3.2.15) via: | |
activerecord-3.2.15, meta_search-1.1.3, activeadmin-0.6.2 | |
Activated activesupport-3.2.15 instead of (= 4.0.0) via: | |
railties-4.0.0, devise-3.1.0, activeadmin-0.6.2 |
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
class ApplicationController < ActionController::Base | |
# Overwrite Devise's authenticate_user! to store where they should be redirected back to | |
def authenticate_user!(opts={}) | |
session[:user_return_to] = request.referrer | |
super(opts) | |
end | |
# Change redirect after Devise login; defaults to root_url | |
def after_sign_in_path_for(user) | |
stored_location_for(user) || dashboard_path |
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
Started GET "/" for 127.0.0.1 at 2013-11-05 10:20:01 +0800 | |
ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations" | |
Processing by PagesController#home as HTML | |
JobSpecialty Load (1.3ms) SELECT "job_specialties".* FROM "job_specialties" | |
Rendered application/_region_select.html.haml (1.9ms) | |
Rendered application/_job_search.html.haml (1558.8ms) | |
Rendered application/_banner.html.haml (1563.6ms) | |
Cache digest for pages/home.html: 2582a0d4c5e51f7cf18c551cceb4eb3c | |
Read fragment views/home/2582a0d4c5e51f7cf18c551cceb4eb3c (0.2ms) | |
Write fragment views/home/2582a0d4c5e51f7cf18c551cceb4eb3c (1.3ms) |
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
class User | |
# Downsides - when first name is nil, you'll have a string like " LastName" | |
def full_name | |
"#{first_name} #{last_name}" | |
end | |
# Downsides - a bit harder to understand | |
def full_name | |
[first_name, last_name].compact.join(' ') | |
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
Parameters: {"title"=>"This should do it", "sub_categorisations_attributes"=>[{"sub_category_id"=>3}, {"sub_category_id"=>4}], "product"=>{"title"=>"This should do it"}} |
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
<%= form_for [@page, @page.notes.new] do |f| %> | |
<%= f.text_area :body %> | |
<%= f.submit %> | |
<% end %> |