macOS 10.15.5 Rails 5.2.4.2 Docker 19.03.12
The outline of the original application is the development of a simple memo application that is conscious of the CRUD system. We paid attention not to lack practicality even if it was a simple application. I implemented it so that the layout does not collapse even if the number of lines increases, and I also set the character limit and blank items so that they are not newly created.
The framework used Rails with Docker. And it's open to the public on Heroku.
Regarding HTML, the class name etc. used the learning site as a hint, and the design was inspired by the learning site, but the implementation was all self-propelled. I repeated the learning site many times in advance regarding the implementation of Rails functions, and after thinking about CRUD functions, I created this time. Therefore, I did not refer to the site as much as possible for short codes, implemented them with the contents I learned, and basically performed all command operations only with the contents I had in mind.
The list page is set as the top page, and links are specified so that individual details can be displayed for the memo items. At that time, we implemented so that newly posted items move to the top.
lists_controller.rb
class ListsController < ApplicationController
def index
@lists = List.all.order(created_at: :desc)
end
On the newly created page, blank content and content of 141 characters or more are not executed.
list.rb
class List < ApplicationRecord
validates :content, {presence: true, length: {maximum: 140}}
end
You can see the individual details page by navigating from the link of each item in the memo list. From there you can "edit" and "delete".
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
I want to acquire skills as a self-propelled engineer! With that in mind, I often ask myself what kind of method is the way to get closer to such an engineer. This time I thought about creating this simple memo app because I wanted to completely incorporate Rails' CRUD functions and MVC, so I summarized it in this simplicity. In the future, I would like to work on creating apps that have functions such as login function and page creation with access authority for each user!
Recommended Posts