Ruby on Rails - creating a application in ruby on rails - ruby on rails tutorial - rails guides - rails tutorial - ruby rails



How to Creating a Application in ruby on rails?

  • Open up a command line or terminal. To generate a new rails application, use rails new command followed by the name of our application:
$ rails new my_app
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team

This example assumes Ruby and Ruby on Rails have already been installed properly. Open up a command line or terminal. To generate a new rails application, use rails new command followed by the name of your application: $ rails new my_app If you want to create your Rails application with a specific Rails version then you can specify it at the time of generating the application. To do that, use rails _version_ new followed by the application name:

$ rails _4.2.0_ new my_app 
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
  • This example assumes Ruby and Ruby on Rails have already been installed properly. If not, you can find how to do it here.
  • Open up a command line or terminal. To generate a new rails application, use rails new command followed by the name of your application:
  • $ rails new my_app
  • If you want to create your Rails application with a specific Rails version then you can specify it at the time of generating the application. To do that, use rails _version_ new followed by the application name:
  • $ rails _4.2.0_ new my_app
  • This will create a Rails application called MyApp in a my_app directory and install the gem dependencies that are already mentioned in Gemfile using bundle install.
  • To switch to your newly created app's directory, use the cd command, which stands for change directory
$ cd my_app
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team

The my_app directory has a number of auto-generated files and folders that make up the structure of a Rails application. Following is a list of files and folders that are created by default:

File/Folder Purpose
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 setup, update, deploy or run your application.
config/Configure your application's routes, database, and more.
config.ruRack configuration for Rack based servers used to start the application.
db/Contains your current database schema, as well as the database migrations.
Gemfile Gemfile.lockThese 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 seen by the world as-is. Contains static files and compiled assets.
RakefileThis file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails.
README.mdThis 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 etc
test/Unit tests, fixtures, and other test apparatus.
temp/Temporary files (like cache and pid files).
vendor/A place for all third-party code. In a typical Rails application this includes vendored gems.

Now you need to create a database from your database.yml file:

rake db:create
# OR
rails db:create
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
rake db:create
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team

Now that we've created the database, we need to run migrations to set up the tables:

5.0
rake db:migrate
# OR
rails db:migrate
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
5.0
rake db:migrate
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team

To start the application, we need to fire up the server:

$ rails server
# OR
$ rails s
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team

By default, rails will start the application at port 3000. To start the application with different port number, we need to fire up the server like,

$ rails s -p 3010
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team

If you navigate to http://localhost:3000 in your browser, you will see a Rails welcome page, showing that your application is now running.

If it throws an error, there may be several possible problems:

  • There is a problem with the config/database.yml
  • You have dependencies in your Gemfile that have not been installed.
  • You have pending migrations. Run rails db:migrate
  • In case you move to the previous migration rails db:rollback

If that still throws an error, then you should check your config/database.yml


This ruby on rails tutorial page provides you the following key areas such as ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby , rails form_for , ruby rails , ruby class , what is ruby on rails , rails installer , ruby online , learn ruby on rails , ruby on rails jobs , rails find_by , install rails , easyrail , rubyonrails , link_to rails , ruby on rails developer , learn ruby the hard way , railscasts , ruby on rails examples , ruby on rails vs php , rails 4 , rails activerecord , rails generate , ruby and rails , ruby on rails download , install ruby on rails , ruby net http , what is rails , ruby app , ruby vs ruby on rails , ruby on rails windows , rails for zombies , ruby on rails book , ruby on rails development , ruby on rails ide , ruby on rails tutorial pdf

Related Searches to creating a application in ruby on rails