User Tools

Site Tools


ruby

This is an old revision of the document!


Table of Contents

Ruby

Rails

Popular Gems

Seed Data

bundle add faker  # Add it to only the development and test groups, if you are a stickler for convention

# In db/seeds.rb
50.times do
  MyModel.create! name: Faker::Name.name
end

rails db:migrate && rails db:seed

Scaffolding

rails g scaffold MyModel field1:string

Data Types:

  • binary
  • boolean
  • date
  • datetime
  • decimal
  • float
  • integer
  • primary_key
  • string
  • text
  • time
  • timestamp
  • references

Example for references:

rails g scaffold Country name:string
rails g scaffold City name:string country:references
ruby.1773476894.txt.gz · Last modified: by reddy

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki