Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby on rails

Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under the MIT License. 
Rails is a model–view–controller framework, providing default structures for a database, a web service, and web pages.
Comment

Ruby on Rails

#Start App
rails new blog
# Create pages
rails g controller pages home about
# Open console
rails c

#Create table
rails g scaffold post title body:text

#Migrate table
rails db:migrate

#To create a new post through the console
rails c
Post.new
@post = Post.new(title: "Tristan", body: "My baby is crying")
@post.save

OR
Post.create(title:"Annita Kerubo", body: "The mother of my child")

#Grab post
@post = Post.find(2)
@post.title

#Get last two posts
@post = Post.last(2)

#Create dev data

10.times do |x|
  Post.create(title: "Title #{x}", body: "body #{x} words go here")
end
rails db:seed

#Create views
rails g migration add_views_to_posts views:integer
rails db:migrate

#Add user setups using devise gem

Add the following line to your Gemfile:
gem 'devise'

bundle install
rails generate devise:install
rails g devise User
rails db:migrate

#To check available routes
rails routes







Comment

PREVIOUS NEXT
Code Example
Ruby :: stripe test keys 
Ruby :: ruby method tap 
Ruby :: ruby name parameters 
Ruby :: ruby string format 
Ruby :: rails generate model with options 
Ruby :: ruby on rails sum nil 
Ruby :: online ruby compiler 
Ruby :: ruby simbolize element from hash 
Ruby :: ruby to_a 
Ruby :: Rails checkbox checked/unchecked values 
Ruby :: run bundle without production in rails 
Ruby :: ruby execute code in string 
Ruby :: generate float array in ruby 
Ruby :: ruby on rails collapse array 
Ruby :: class inheriting multiple modules in ruby 
Ruby :: question mark in ruby 
Ruby :: Missing template clients/show with {:locale=[:en], :formats=[:pdf], 
Ruby :: ruby extract elements from array 
Ruby :: rails class sti reminders 
R :: drop columns by index r 
R :: how to select all the records above a specific datetime in r 
R :: merge multiple data table in r 
R :: write to csv in r 
R :: ggplot2 multiple lines geom_line 
R :: drop na in r 
R :: create vector in r 
R :: how to get quantile summary statistics in r summarise 
R :: truncate string in r 
R :: empty environment r 
R :: R view memory size of variables 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =