Class names are CamelCase
.
Methods and variables are snake_case
.
Methods with a ?
suffix will return a boolean.
This post is also on my blog, since Gist doesn't support @ notifications.
Components are taking center stage in Ember 2.0. Here are some things you can do today to make the transition as smooth as possible:
Ember.Controller
instead of Ember.ArrayController
or Ember.ObjectController
Ember.Controller
, otherwise a proxy will be generated. You can use Ember.RSVP.hash to simulate setting normal props on your controller.class Operation < Struct.new(:name, :args, :block) | |
class << self | |
attr_accessor :opposite_operations | |
end | |
def self.define_opposite_operations(name, name_of_opposite) | |
@opposite_operations ||= {} | |
@opposite_operations[name] = name_of_opposite | |
@opposite_operations[name_of_opposite] = name | |
end |
# Model | |
expect(@user).to have(1).error_on(:username) # checks whether there is an error in username | |
expect(@user.errors[:username]).to include("can't be blank") # check for the error message | |
# Rendering | |
expect(response).to render_template(:index) | |
# Redirecting |
# Clear existing task so we can replace it rather than "add" to it. | |
Rake::Task["deploy:compile_assets"].clear | |
desc "Precompile assets locally and then rsync to web servers" | |
task :compile_assets do | |
# compile assets locally | |
run_locally do | |
with rails_env: fetch(:stage) do | |
execute :bundle, "exec rake assets:precompile" | |
end |
# Clear existing task so we can replace it rather than "add" to it. | |
Rake::Task["deploy:compile_assets"].clear | |
desc "Precompile assets locally and then rsync to web servers" | |
task :compile_assets do | |
on roles(:web) do | |
rsync_host = host.to_s | |
run_locally do | |
with rails_env: :production do ## Set your env accordingly. |
render :inline => '<html><b>123</b></html>' #=> Content-Type: text/html; charset=utf-8 | |
# Good | |
render json: {1 => 2}.to_json #=> Content-Type: application/json; charset=utf-8 | |
# this was correct | |
render xml: '<xml><foo>123</foo></xml>' #=> Content-Type: application/xml; charset=utf-8 |
# env.rb or spec_helper.rb
Capybara.register_driver :poltergeist do |app|
opts = {
extensions: ["#{Rails.root}/features/support/phantomjs/disable_animations.js"] # or wherever
}
Capybara::Poltergeist::Driver.new(app, opts)
end
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 4.0" | |
gem "railties", "~> 4.0" | |
gem "tzinfo" | |
# Let's use thin |
public bool VerifyLicense(string licenseKey, string email) | |
{ | |
if (string.IsNullOrEmpty(licenseKey) || string.IsNullOrEmpty(email)) | |
{ | |
return false; | |
} | |
try | |
{ | |
this.License = this.Decrypt(licenseKey); | |
this.LicenseProcessed = true; |