Subject: What's going on?
Author: Linux
In response to: Rails Probject I -- Hello World
Posted on: 09/10/2017 09:35:13 PM
Without your touch, your default empty web application is ready to go online.
First start the server, which is a built-in Puma.
-- administrator@ubuntu:~/hello_world$ rails server
=> Booting Puma
=> Rails 5.1.4 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.10.0 (ruby 2.4.0-p0), codename: Russell's Teapot
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Secondly, on your browser, type:
Yay! Youre on Rails!
Rails version: 5.1.4
Ruby version: 2.4.0 (x86_64-linux)
It is online! But where is the "Welcome aboard" index page coming from? What's going on here?
First take a look at the routing table: "
/config/routes.rb"
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
It's empty and the deafult should be kicked in. Take a look at the traffic log
Started GET "/" for 127.0.0.1 at 2017-09-10 14:17:31 -0700
Processing by Rails::WelcomeController#index as HTML
Rendering /home/administrator/.rvm/gems/ruby-2.4.0/gems/railties-5.1.4/lib/
rails/templates/rails/welcome/index.html.erb
Rendered /home/administrator/.rvm/gems/ruby-2.4.0/gems/railties-5.1.4/lib/
rails/templates/rails/welcome/index.html.erb (4.3ms)
Completed 200 OK in 198ms (Views: 10.0ms)
As the log indicates, the "Welcome aboard" page is coming from "
lib/rails/templates/rails/welcome/index.html.erb"
>
> On 09/10/2017 08:16:45 PM
Linux wrote:
Step 1 Create a new Rails project
Rails comes with a number of scripts called generators that are designed to make your development life easier by creating everything that's necessary to start working on a particular task. One of these is the new application generator, which will provide you with the foundation of a fresh Rails application so that you don't have to write it yourself.
-- administrator@ubuntu:~$ rails new hello_world
create
create README.md
create Rakefile
create config.ru
create .gitignore
create Gemfile
run git init from "."
Initialized empty Git repository in /home/administrator/hello_world/.git/
create app
create app/assets/config/manifest.js
create app/assets/javascripts/application.js
create app/assets/javascripts/cable.js
create app/assets/stylesheets/application.css
create app/channels/application_cable/channel.rb
create app/channels/application_cable/connection.rb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/jobs/application_job.rb
create app/mailers/application_mailer.rb
create app/models/application_record.rb
create app/views/layouts/application.html.erb
create app/views/layouts/mailer.html.erb
create app/views/layouts/mailer.text.erb
create app/assets/images/.keep
create app/assets/javascripts/channels
create app/assets/javascripts/channels/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create bin/setup
create bin/update
create bin/yarn
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/secrets.yml
create config/cable.yml
create config/puma.rb
create config/spring.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/application_controller_renderer.rb
create config/initializers/assets.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/cookies_serializer.rb
create config/initializers/cors.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_framework_defaults_5_1.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/apple-touch-icon-precomposed.png
create public/apple-touch-icon.png
create public/favicon.ico
create public/robots.txt
create test/fixtures
create test/fixtures/.keep
create test/fixtures/files
create test/fixtures/files/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/test_helper.rb
create test/system
create test/system/.keep
create test/application_system_test_case.rb
create tmp
create tmp/.keep
create tmp/cache
create tmp/cache/assets
create vendor
create vendor/.keep
create package.json
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_5_1.rb
run bundle install
This will create a Rails application called hello_world in a hello_world directory with all necessary folders and files generated.
Among them, the most important ones are:
config -- the directory with configuration files, e.g. routes.rb
app/controllers-- the directory holding controllers
app/models-- the directory holding models
app/views-- the directory holding views
References: