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
# I have seen people writing something like: | |
users.collect{|u| u.tasks.size}.sum | |
# This can also be written as | |
users.sum{|u| u.tasks.size} |
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
Only show commit history earlier than 5 days ago: | |
git log --since=5.day.ago | |
Only show commit history older than 5 days ago: | |
git log --until=5.day.ago | |
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
# Rails Edge: Custom Flash Types | |
# | |
#Rails just got some syntactic sugar for dealing with flash messages in | |
#your controllers and views. | |
# | |
#You can now declare the following in your controllers: | |
# | |
class ApplicationController | |
add_flash_types :error, :warning |
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
Allow scaffold/model/migration generators to accept a polymorphic modifier for references/belongs_to, for instance | |
rails g model Product supplier:references{polymorphic} | |
will generate the model with belongs_to :supplier, polymorphic: true association and appropriate migration. |
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
# Edge rails you can do: | |
create_join_table :products, :categories | |
# Earlier: | |
create_table :categories_products, :id => false do |td| | |
td.integer :product_id, :null => false | |
td.integer :category_id, :null => false |
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
# cattr_accessor | |
class Base | |
cattr_accessor :settings | |
# def self.settings | |
# @@settings | |
# end | |
# def self.settings=(value) |
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
Beginner’s Guide to Responsive Web Design | |
http://blog.teamtreehouse.com/beginners-guide-to-responsive-web-design | |
Responsive Web Design, by- ETHAN MARCOTTE | |
http://www.alistapart.com/articles/responsive-web-design/ | |
E-Book on Responsive web design, by - ETHAN MARCOTTE | |
http://www.abookapart.com/products/responsive-web-design | |
A Presentation on Responsive Design: |
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
# In rails 3.2, it's creating custom error pages is much more easier: | |
# | |
# Add this to config/application.rb: | |
config.exceptions_app = self.routes | |
# That causes errors to be routed via the router. Then you just add to config/routes.rb: | |
match "/404", :to => "errors#not_found" |
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
Hey there! And welcome to my little mailing list about writing faster Rails tests. | |
My goal is to send you only focused, actionable info that will help you speed up your test suites right away. Let's get started! | |
The first thing we'll cover is the leading cause of test slowness in Rails apps: bloated fixtures. | |
Here's an example of a test that will run far slower than it needs to (using factory_girl (a great tool, despite its involvement in this test's slowness)): | |
describe "#full_name" do |
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
bundle exec rake gb:sync_taxon RAILS_ENV='gardners_staging' | |
rake aborted! | |
Couldn't find Spree::Taxon with id=949 | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:343:in `find_one' | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in `find_with_ids' | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in `find' | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/querying.rb:5:in `find' | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/bundler/gems/spree-59399e6f5d29/core/app/models/spree/taxon.rb:39:in `set_permalink' | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/callbacks.rb:418:in `_run__1436883041183878916__create__1200570912174408727__callbacks' | |
/var/www/Konga-Staging/shared/bundle/ruby/1.9.1/gems/activesupport-3.2.13 |
OlderNewer