Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

rails generate model

rails generate model Article title:string body:text


[Output]

invoke  active_record
create    db/migrate/<timestamp>_create_articles.rb
create    app/models/article.rb
invoke    test_unit
create      test/models/article_test.rb
create      test/fixtures/articles.yml
Comment

rails generate model with options

class Article < ApplicationRecord
  has_many :comments

  validates :title, presence: true
  validates :body, presence: true, length: { minimum: 10 }

  VALID_STATUSES = ['public', 'private', 'archived']

  validates :status, inclusion: { in: VALID_STATUSES }

  def archived?
    status == 'archived'
  end
end
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails trackable to devise 
Ruby :: config.factory method syntax rails 
Ruby :: button in rails 
Ruby :: array ruby taking 3 last value 
Ruby :: ruby constructor 
Ruby :: simple form for rails dates 
Ruby :: rails link_to class 
Ruby :: rails video_tag with <source 
Ruby :: ruby loop through array from last item backwards 
Ruby :: ruby regexp match all 
Ruby :: how to get current month end date in ruby 
Ruby :: length validation rails 
Ruby :: rails check if key exists 
Ruby :: ruby how to loop through an array 
Ruby :: ruby write csv file 
Ruby :: Ruby ruby-2.6.3 is present on the following stacks: heroku 16 
Ruby :: ruby is character 
Ruby :: rails check if a URL is valid 
Ruby :: ruby for each continue 
Ruby :: droptable rails 
Ruby :: rspec gem tutorial 
Ruby :: Blocked host: c25f383bd08f.ngrok.io 
Ruby :: manage ruby versions 
Ruby :: rails link_to example 
Ruby :: how to add variable inside string ruby 
Ruby :: In Jekyll - get the parent url path of a collection with concatenation 
Ruby :: ruby execute code in string 
Ruby :: how to open ruby console 
Ruby :: rspec log to console 
Ruby :: ruby create a copy of variable 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =