Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Activesupport - Leckerbissen (Kurzvortrag)

372 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Activesupport - Leckerbissen (Kurzvortrag)

  1. 1. ActiveSupportLeckerbissen
  2. 2. Utility classes and standard library extensions from Rails require ‘active_support/all’ require ‘active_support/core_ext/string’
  3. 3. Klassikervariable.blank? #=> truevariable.present? #=> false[0,1,2,3].first #=> 0[0,1,2,3].second #=> 12.months.ago #=> 2012-04-15 19:30:00 +0200
  4. 4. unshift => prependa = [1,2,3,4]a.prepend(0) #=> [0,1,2,3,4]a.prepend(-1,0) #=> [-1,0,1,2,3,4]
  5. 5. in_groups_of%w(1 2 3 4 5 6 7).in_groups_of(3) {|group| p group} ["1", "2", "3"] ["4", "5", "6"] ["7", nil, nil]
  6. 6. module Config mattr_accessor :urlendclass PlaceholderImage cattr_accessor :base_pathendConfig.url = “http://www.freebsd.org”PlaceholderImage.base_path = “/images” => ActiveSupport::Configurable
  7. 7. Rails 4 BetaNumberHelpers von ActionView nach ActiveSupportverschoben1234567.to_s(:human_size) #=> "1.18 MB"302.243989234.to_s(:percentage, :precision => 5) #=> 302.24399%
  8. 8. ENDE

×