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
require 'integration/spec_helper' | |
class Article | |
include Virtus | |
attribute :title, String | |
def title | |
super || '<unknown>' | |
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 ThisWorks | |
def self.const_missing(*args) | |
p "yay!" | |
end | |
NonExistingConstant | |
end | |
this_does_not_work = Class.new do | |
def self.const_missing(*args) |
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
require 'delegate' | |
class BasicDecorator < SimpleDelegator | |
def self.decorate(objects) | |
case objects | |
when Array | |
objects.map { |object| new(object) } | |
when ActiveRecord::Relation, DecoratedListProxy, ActiveRecord::Associations::CollectionProxy | |
DecoratedListProxy.new(self, objects) | |
else |
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
#!/usr/bin/env ruby | |
current_branch = `git symbolic-ref --short HEAD`.chomp | |
if current_branch != "master" | |
if $?.exitstatus == 0 | |
puts "WARNING: You are on branch #{current_branch}, NOT master." | |
else | |
puts "WARNING: You are not on a branch" | |
end | |
puts |
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
user system total real | |
variable 1.590000 0.000000 1.590000 ( 1.599274) | |
AR 69.490000 2.440000 71.930000 ( 71.920999) | |
AR is 44.97 times slower. |
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
railties :: (refactor_plugin_new_generator) » ./bin/rails plugin new ~/Projects/playground/rails/full_engine --full | |
create | |
create README.rdoc | |
create Rakefile | |
create full_engine.gemspec | |
create MIT-LICENSE | |
create .gitignore | |
create Gemfile | |
create app/models | |
create app/models/.keep |
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 User < ActiveRecord::Base | |
validates :account_id, :presence => true | |
end | |
# in the View (using simple_form): | |
# | |
# f.select :account, :collection => Account.all |
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
<%= form_for(@post) do |f| %> | |
<% if @post.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> | |
<ul> | |
<% @post.errors.full_messages.each do |msg| %> | |
<li><%= msg %></li> | |
<% end %> | |
</ul> |
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
diff --git a/lib/spring.rb b/lib/spring.rb | |
index 38a22bf..20669c6 100644 | |
--- a/lib/spring.rb | |
+++ b/lib/spring.rb | |
@@ -50,6 +50,7 @@ class Spring | |
end | |
def run(args) | |
+ puts "#run" | |
boot_server unless server_running? |
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 Article < ActiveRecord::Base | |
end | |
module Posts | |
end | |
Posts::Builder # => uninitialized constant Posts::Builder | |
Article::Builder # => ActiveRecord::Associations::Builder | |
Post.const_get('Builder') # => ActiveRecord::Associations::Builder |