Code School - Rais 4 Zombie Outlaws #1
Rails 4: Zombie Outlaws - Code School
Routes
- routes
- match廃止
- via (method)
- PATCHが追加された (PUTの代わり)
- patch :update (controller test)
- Nested resources
- concern :sociable do |options|
- resources :messages, concerns: :sociable
- app/concerns/sociable.rb
- self.call
- Remove whiny nils
- nil.id #=> 4, nil.object_id
- ruby 1.8.7
- Rails 4 requires ruby 1.9.3
- thread
- rails3 config.threadsafe!
- rails4
- config.cache_classes = true
- config.eager_load = true
- puma server
ActiveRecord / Model
- Deprecated
- find(:all, :conditions
- find_all_by_title
- find_by_title -> find_by(:title =>
- find_or_initialize_by_title -> find_or_initialize_by
- update_attributes -> update
- .scoped -> .all
- New method
- where .first_ir_create
- find_or_create_by
- update_columns (skip validations)
- Always use proc for scope
- scope :recent, -> { where }
- default_scope :recent, -> { where }
- empty array [] -> Post.none
- Chainable (visible_posts.recent)
- IS NOT NULL -> `post.where.not(:name )
- Order
- order changed for multipe conditions
- 'created_at DESC' -> created_at: :desc
- Reference
- where(name: ).references(:comments)
- where(comments: {name: })
include ActiveModel::Model
- Naming, Translation, Validations, Conversion
String parameters
- params.requires(:user).permit(:admin)
- all unpermitted parameters will get logged
- can be changed with config.
- attr_accessible -> gem 'protected_attributes'
- Authenticity token
- remote: true -> meta tag csrf_token
- can be changed with config.action_view.embed_authenticity_token_in_remote_forms
- protect_from_forgery with: exception
- :null_session
- :reset_session
Filters, Session, Flash
- filters
- before_filter -> before_action
- session
- flash
- custom flash types
- add_flash_types :grunt, :snarl
- custom flash types
再生スピードが変更できるようになった
ビデオダウンロードの形式が選べる
アニメーションのクオリティが上がり続けている
strong parametersのくだりがよくわからない
面倒になったのか、より安全になったのか