Roughly the flow of web application development with Rails.

Perfect for myself.

Version change of ruby with rvm

terminal.


$ rvm install 2.5.1
$ rvm use 2.5.1

Create an app with Rails by specifying the version

terminal.


$ gem install rails -v 5.2.1 -N #6 for 6 series.0.2.1 or whatever.
$ rails _5.2.1_ new < app name >

Install the required gems

Gemfile.


gem 'bootstrap', '~> 4.1.1'
gem 'jquery-rails', '~> 4.3.1'

gem 'bycript' #Since it is prepared from the beginning, uncomment it

Other useful gems

・ Pagination gem'kaminari'kaminari x Rails6

-User authentication implementation gem'device' "How to use device"

Other summary articles etc. ・ 15 Ruby on Rails Gem that you will definitely want to use for beginners ・ Qiita article "Convenient Gem you should know if you do Rails"

Finally

terminal.


$ bundle install 

Set up a server and check with a browser

terminal.


$ rails s -p Arbitrary port number#-It is ok even if there is no less than p. If not specified, it will be 3000

Access localhost: 3000 (or the specified port number) with a browser, and if the following page is displayed, it is ok Screen Shot 2020-08-07 at 16.20.10.png

Modeling

For login system and user authentication function

terminal.


$ rails generate model User name:string email:string password_digest:string

For content such as blogs

terminal.


$ rails generate model Articles title:string description:text 

I want to add it later (for example, adding user_id to the Articles model)

Add the following to the created migrate file

class AddUserIdToArticles < ActiveRecord::Migration[5.1]
  def change
    add_column :articles, :user_id, :int
  end
end

Finally

terminal.


$ rails db:migrate

Controller and view creation

terminal.


$rails g controller Users index(If you make a user list) new edit

$rails g controller Home index

$rails g controller Sessions new #For login

Push to Github

$ git init #Create a local repository
$ git add .
$ git commit -m "first commit"
$git remote add origin URL of the repository created on Github
$ git push origin master

Branch commands

~ Create a new branch ~
$git branch Any branch name

~ Check for existing branches ~
$ git branch

~ Move to the branch you want to write ~
$git checkout The name of the branch you want to move

~ Push to the branch destination ~
$ git add .
$ git commit -m "first commit"
$git push origin The name of the branch you want to write

Merge commands

== Select the import destination branch ==
$ git checkout master

== Combine the branches you want to integrate into mater ==
$git merge The name of the branch you want to merge

== Send join information to GitHub ==
$ git push origin master

Ruby code summary that tends to be written in the view

hoge.html.erb



#link_to
<%= link_to 'top page', root_path %>
<%= link_to “Move to Yahoo”, “http://www.yahoo.co.jp/” %>
<%= link_to “Delete”, member_path(params[:id]), method: :delete %>

Recommended Posts

Roughly the flow of web application development with Rails.
Comparison of WEB application development with Rails and Java Servlet + JSP
Start web application development with Spring Boot
[Probably the easiest] WEB application development with Apache Tomcat + Java Servlet
Perform a large amount of csv export (output) of log information etc. on the WEB application with Rails application
[Rails] Development with MySQL
Docker the development environment of Ruby on Rails project
Control the processing flow of Spring Batch with JavaConfig.
[SPA development with Rails x Vue] Learn the basics of Vue.js (Overview of vue.js, template syntax)
[Rough explanation] How to separate the operation of the production environment and the development environment with Rails
Web application built with docker (1)
Rails web server and application server
Web application development memo with MVN, Tomcat, JSP / Servlet with VScode
The first WEB application with Spring Boot-Making a Pomodoro timer-
Check the operation of two roles with a chat application
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
[Personal development] 8 things I did after publishing the web application
The story of the first Rails app refactored with a self-made helper
Let's roughly implement the image preview function with Rails + refile + jQuery.
About the basics of Android development
Explanation of the order of rails routes
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
[Rails / Heroku / MySQL] How to reset the DB of Rails application on Heroku
Check the migration status of rails
Build a web application with Javalin
[Rails] I tried deleting the application
Spring5 MVC Web application development with Visual Studio Code Environment construction (Installation of JDK11, Maven, Tomcat, Visual Studio Code)
I tried to take a look at the flow of Android development environment construction with Android Studio
Web application creation with Nodejs with Docker
Install Rails in the development environment and create a new application
Incident (rails) that is logged out when user editing of the application
Web application structure by Java and processing flow in the presentation layer
Spring5 MVC Web application development with Visual Studio Code Spring Security usage 1/3 [Preparation]
How to decorate the radio button of rails6 form_with (helper) with CSS
Android application: Let's explain the mechanism of screen transition with simple code
Spring Boot2 Web application development with Visual Studio Code SQL Server connection
Spring5 MVC web application development with Visual Studio Code SQL Server connection
Creating a java web application development environment with docker for mac part1
I examined the flow of TCP communication with Spring Integration (client edition)
I examined the flow of TCP communication with Spring Integration (server edition)
Spring5 MVC Web application development with Visual Studio Code Maven template creation
Create a java web application development environment with docker for mac part2
[Rails] Articles for beginners to organize and understand the flow of form_with
Get the value of enum saved in DB by Rails with attribute_before_type_cast
Check the contents of params with pry
Create a simple web application with Dropwizard
[Swift] Vaguely grasp the flow of Delegate
The identity of params [: id] in rails
part of the syntax of ruby ​​on rails
Prepare the format environment with "Rails" (VScode)
[Rails] Change the label name of f.label
Personal application production 2 Introduction of WEB fonts
Check the processing contents with [rails] binding.pry
Rails Basics of creating a new application
About the treatment of BigDecimal (with reflection)
The process of introducing Vuetify to Rails
About the mechanism of the Web and HTTP
Format the contents of LocalDate with DateTimeFormatter
Check the version of the standard Web software.
Role of JSP in Web application [Java]
Run WEB application with Spring Boot + Thymeleaf