Rails
- Benefits
- Huge leap in developer productivity
- Reduced time to market
- One can build and deploy an app in a day
- Scaling & Scalability
- Scaling is an architecture concern
- Architecture, Databases, Caching, Queues, CDNs, Load Balancers
- Not too much to do with the performance of a language or a framework
- Hulu is handling almost 10M unique visitors per month
- Data Modelling
- Associations
- Polymorphic Associations - A model belongs to more than 1 other models on a single association.
- Self Referential Association
- Single Table Inheritance
- Eager Loading - loads the associations in advances
includes
- Lazy Loading
- N+1 Query Problem
- Query Interface
- pure string condition - not recommended. May cause sql injection security threat
- array condition - recommended
- hash condition - readable
- CommandLine
rails c --sandbox
- does not make any changesrails s
rails generate
rails dbconsole
rails new appname
- rake
- Short for ruby make
- Runs administrative tasks using rakefile
- Tasks have the file extension
.rake
rake -T
lists all the different tasks availablerake namespace::taskname
- rake tasks can have callbacks
- rspec, capistrano are built on rake
- Avoid writing complex logic in tasks. Call model methods instead.
rake
vsrails r
- rake does not boot rails. Since booting rails is expensive, use rails runner only if required- Alternative - Thor
- Routing
- Rails routing is centered around resources
- You can add constraints to specify protocol and subdomain
- Levels of logging
:debug, :info, :warn, :error, :fatal
-
Categories
-
Database
-
Programming
-
Workflow
-
Devops
-
Architecture
-
Ui
-
Frameworks
-
Blogging