Tabless Model

Tram Ho

1. Introduction to the problem:

  • When working on a project, all data will be processed through the model and saved in the DB, such as user information, products, invoices ….
  • However, there are also some data that act as the master data of the system and do not need to be stored in the DB but still need to be processed through the model, for example 12 grade blocks, alphabets, etc.
  • Today I will introduce some ways that I have dealt with the above problem.

2. Tabless Actice Record Model:

  • I will create the Letter class and implement the necessary functions as a real model
  • Here I have implemented some functions so Letter can be used as ActiveRecord of Rails.
  • Can you continue implementing other methods like Letter.first , Letter.last , letter.valid? , ….
  • You can also create LettersController for Letter as normal model



    < ul class = “pager” >
    < % @letters . each do | letter | %>
    <li>
    < %= link_to letter.char.upcase, letter_path(id: letter.char), class: (“active” if params
Share the news now

Source : Viblo