Databases in Rails
- Each time we run the scaffold generator in web application, Rails created a database migration file and placed it in the db/migrate directory.
- Rails uses the
rakecommand to run these migrations, which creates a schema, from which appropriate databases can then be created.
- Because migrations can also be used to undo the work of previous migrations (e.g., to make corrections), they are timestamped, and executed in the order they were created. The filename contains the timestamp.
- Rails automatically sets up applications to run in one of three prebuilt environments (you can also add your own)
- Development - Used when you are developing the application.
- Test - Used when you run test.
- Production- Used when you deploy your application.
- By default, when you run
$ rails server
Rails runs in the development environment.
- To force rails to run in a different environment, use
$ rails server -e production
One of the architectural elements most likely to differ between development and production environments is the database:
- During development, you (the developer) are the only one accessing the database.
- Rails automatically sets up the development environment to use SQLite, a simple easy-to-use file-based relational database that runs in memory. SQLite is not a production grade database.
- When an application goes into production, it may receive 100’s or 1000’s of “hits” in a matter of seconds, and the database needs be able to handle the data requests associated with these hits.
- Popular production database include: PostgreSQL and MySQL.
- The databases that Rails will use in different environments is specified in: db/database.yml.
- Dependency injection
- Directives and Pipes
- Data binding
- HTTP Get vs. Post
- Node.js is everywhere
- MongoDB root user
- Prefer Async Script Loading
- Components, Bootstrap and DOM
- What is HEAD in git?
- Show the changes in Git.
- What is AngularJS 2?
- Confidence Interval for a Population Mean
- Accuracy vs. Precision
- Sampling Distribution
- Working with the Normal Distribution
- Standardized score - Z score
- Evaluating the Normal Distribution
- What is Nodejs? Advantages and disadvantage?
- How do I debug Nodejs applications?
- Sync directory search using fs.readdirSync