LoginSignup
0
0

More than 1 year has passed since last update.

WEB開発をやり始めてみる(Rails:Cloud9環境設定)

Posted at

目的

Railsの環境を整えるのをCloud9上でやってみます。

やったこと(環境整備)

$ rails -v
Rails 7.0.4

$ mkdir rails_projects
$ cd rails_projects/

### railsを新しく作成
$ rails _7.0.4_ new hello

### gemファイル内読み込み
$ bundle install

やったこと(簡単なものの表示)

### Usersはコントローラーの名前
### indexはメソッドの名前
$ rails g controller Users index 
app/controllers/users_controller.rb
### 上記で作成したUsersコントローラーが作成されています(ApplicationControllerを参照しています)
### indexメソッドが作成されています
class UsersController < ApplicationController
  def index
  end
end

/app/views/users/index.html.erb
### HTMLにRubyプログラムを書くことができるのがerb
<h1>HELLO WORLD</h1>
/config/routes.rb
### どこにアクセスしたらどこを表示するかの設定を行います。
### URL/users/indexの設定になっている
Rails.application.routes.draw do
  get 'users/index'
  # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

  # Defines the root path route ("/")
  # root "articles#index"
end

### rootの設定になっている
Rails.application.routes.draw do
  root 'users#index'
  # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

  # Defines the root path route ("/")
  # root "articles#index"
end

### 現在のルーティングの設定が一覧できます。
$ rails routes
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0