Ride on the Fast Track of Web with Ruby on Rails
-
Upload
nascenia-it -
Category
Technology
-
view
1.156 -
download
0
description
Transcript of Ride on the Fast Track of Web with Ruby on Rails
Ruby on Rails
Ride on the fast track of web
“Accumulated knowledge of the
world to your fingertip”
“We are the masters
They are the slaves”
2.days.ago =>Thu, 23 Feb 2012 14:11:45 EST -05:00
‘fuad bin omar’.reverse =>ramo nib dauf
‘fuad bin omar’.capitalize =>Fuad bin omar
‘fuad bin omar’.length =>13
+
Convention
Configuration
Over
One Class Per Table
Class User < ActiveRecord::Base
end
Validations
Class User < ActiveRecord::Base
validates_presence_of :login,:name
validates_uniqueness_of :login
end
class User < ActiveRecord::Base
has_many :posts
end
class Post< ActiveRecord::Base
belongs_to :user
end
User.create!(:login => ‘fuad’,
:name => ‘Fuad Omar’)
user = User.new(:login =>
‘fuad’, :name => ‘Fuad Omar’)
user.save!
user = User.new
user.login = ‘fuad’
user.name = ‘Fuad Omar’
user.save!
user = User.first
user = User.find(12)
user = User.find_by_name(‘Fuad’)
posts = user.posts
user = User.find(12)
posts =
user.posts.where(‘created_at >’,
7.days.ago)
posts = posts.order(‘title‘)
user = User.find(1)
user.name = ‘Fuad Bin Omar’
User.save
Fuad Omar
COO
www.nascenia.com
www.facebook.com/nascenia
www.linkedin.com/in/fuadomar
2,35,000
Fuad Omar
COO
www.nascenia.com
www.facebook.com/nascenia
www.linkedin.com/in/fuadomar