· 1 min read
Screencast: Upgrade auf Rails 3.2
Downloads in verschiedenen Formaten:
Resourcen:
Gemfile
[ruby] gem ‘rails’, ‘3.2.0’ group :assets do gem ‘sass-rails’, ” > 3.2.3” gem ‘coffee-rails’, ”> 3.2.1” gem ‘uglifier’, ’>= 1.0.3’ end [/ruby]
terminal
[bash] bundle update rails g model product_variation product_id:integer:index name ‘price:decimal{7,2}’ rails g migration add_properties_to_product_variations properties:text rake db:migrate echo -d postgresql -T > ~/.railsrc [/bash]
rails console
[ruby] puts Product.order(:name).explain ActiveRecord::Base.silence_auto_explain { Product.order(:name) } Product.pluck(:name) Product.pluck(:id) Product.select(:name).uniq Product.where(name: “Foo”).first_or_create! Product.where(name: “Foo”).first_or_create!(price: 5) “Product”.safe_constantize p = ProductVariation.new(color: ‘blue’, size: 3) p.color p.size p.properties[:color] [/ruby]
config/development.rb
[ruby] # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) config.active_record.auto_explain_threshold_in_seconds = 0.5
config.log_tags = [:uuid, :remote_ip] [/ruby]
config/test.rb
[ruby] # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict [/ruby]
models/product_variation.rb
[ruby] store :properties, accessors: [:color, :size] [/ruby]