The Rails Philosophy:
DRY – “Don’t Repeat Yourself”
Convention Over Configuration:
Means that Rails makes assumptions about what you want to do and how you’re going to do it, rather than requiring you to specify every little thing through endless configuration files.
Above command generate new rails application based on current rails version. The number of different options is available.
Use of MVC framework.
RVM (Ruby enVironment Manage)
rails new demo
Above command generate new rails application based on current rails version. Number of different options are available.
rails new demo -d mysql
rails new demo -d postgresql
Directories structure in Rails:
App/ – Contains the controllers, models, views, helpers, mailers, and assets for your application
Bin/ – Contains the rails script that starts your app and can contain other scripts you use to deploy or run your application.
Config/ – Configure your application’s runtime rules, routes, database, and more
Config.ru – Rack configuration for Rack-based servers used to start the application.
Db/ – Your current database schema, as well as the database migrations files.
Gemfile & Gemfile.lock – These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem
Lib/ – Extended modules for your application.
Log/ – Application log files.
Public/ – The only folder is seen to the world as-is. Contains the static files and compiled assets.
Rakefile – This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile, you should add your own tasks by adding files to the lib/tasks directory of your application.
README.doc – This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on.
Test/ – Unit tests, fixtures, and other test apparatus.
Tmp/ – Temporary files (like cache, PID and session files)
Vendor/ – A place for all third-party code. In a typical Rails application, this includes Ruby Gems and the Rails source code (if you optionally install it into your project).
Encoding : (utf8 / Unicode)
Database: (name of database)
Username: (username of the database)
Password: (password for the database)
Socket: (For MySQL)
Dynamic Generator for all resources
Rails scaffolding is a quick way to generate some of the major pieces of an application.
Scaffolding will generate controller, model, views for new Resource in a single command.
rails generate scaffold Post title:string text:text
Database creation & Migration
Various options are available for Database creation/migration…
Migrations are available for database table creation/database changes
This file holds all database details with all tables in the current project.
Available in config/routes.rb
‘rake routes’ command will list all routes present in current application.
For generating and use any routes ‘resources needs to add in routes.rb’ file.
‘resources : posts’ this is an example of added resource ‘posts’
Find below Post for more information:
Learn about Rails Unit Testcases:
Learn more about Rails – https://guides.rubyonrails.org/