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 :: comparator.constructors[0].newInstance([domainClass] in grails 3 
R :: add a vertical line in ggplot 
R :: update r from rstudio 
R :: how to count the number of NA in r 
R :: list all installed packages in r 
R :: how to count the true values in r 
R :: WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding: 
R :: how to append in a list in R 
R :: R regress one variable on all the other variables 
R :: r read all files in folder 
R :: create file in r 
R :: pi in r 
R :: comment in r 
R :: how to do logistic regression in r 
R :: find length of a list or vector in r 
R :: r variables 
R :: fill the na data in mean value in r 
R :: replace any NA in a data frame in r 
R :: r prepend to a list 
R :: How to calculate standardized residuals in R 
R :: calculated defualt values in R function parameters 
R :: ggplot2 reverse order of scale_brewer color 
R :: r select columns by vector of names 
R :: check argument of function in r 
R :: store list in data.frame R 
R :: timestamp conversion from excel R 
R :: how to change column names in r 
Rust :: rust sum vector 
Rust :: how to create a vector in rust 
Rust :: rust new vec 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =