[Ruby] Commentary on completing the original application

2 minute read

environment

macOS 10.15.5 Rails 5.2.4.2 Docker 19.03.12

Overview

The outline of the original application is the development of a simple memo application that considers the CRUD system. Even though it was a simple app, we paid attention so as not to be practical. The layout was implemented so that the layout would not be broken even if the number of lines increased, and settings were made so that character limits and blank items were not created.

The framework used Rails with Docker. And it is published by Heroku.

About originality

Regarding HTML, I used the learning site as a hint for the class name and the like, and the design was inspired by the learning site, but the implementation was all self-propelled. Regarding the implementation of Rails function, I repeated the learning site many times in advance, and made this time after keeping in mind the CRUD function. Therefore, I did not refer to the site etc. as much as possible, I implemented the contents that I learned, and basically did all the command operations with the contents in mind.

About the site

Screenshot 2020-08-01 23.23.27.png The list page is set as the top page, and links are specified so that the details of each memo item can be displayed. At that time, I implemented so that the newly posted item moves to the top.

lists_controller.rb


class ListsController <ApplicationController
  def index
    @lists = List.all.order(created_at: :desc)
  end

New page

Screenshot 2020-08-01 23.23.45.png In the newly created page, blank contents and contents of 141 characters or more are set not to be executed.

list.rb


class List <ApplicationRecord
  validates :content, {presence: true, length: {maximum: 140}}
end

Detail page

Screenshot 2020-08-01 23.24.43.png You can view individual detail pages by navigating from the links for individual items in the memo list. From there you can perform “Edit” and “Delete”.

edit page

Screenshot 2020-08-01 23.24.55.png The edit page is implemented so that the contents before editing are displayed when the page is opened.

ruby:edit.html.erb


<div class="form-bady">
  <textarea name="content"><%= @list.content %></textarea>
  <input type="submit" value="edit">
</div>

lists_controller.rb


def edit
  @list = List.find_by(id: params[:id])
end

What I was aware of when creating the original application

I want to acquire skills as an engineer who can run by himself! With that in mind, I often ask myself what kind of method is to approach such an engineer. This time I thought about creating this simple memo app because I thought that the CRUD function of Rails and MVC were completely dropped, so I summarized it in this simplicity. In the future, I would like to work on creating an application that has functions such as a login function and the creation of pages with access rights for each user!