SlideShare a Scribd company logo
1 of 33
Download to read offline
Start
Ruby On Rails
Starter KIT
score: 000000 XP
Level #1
Introduction
score: 000000 XP
What is ruby?
Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was
designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan.
Matsumoto has said that Ruby is designed for programmer productivity and fun, following the
principles of good user interface design
What is rails?
Ruby on Rails, or simply Rails, is a web application framework written in Ruby under MIT
License. Rails is a model–view–controller (MVC) framework, providing default structures for a
database, a web service, and web pages.
score: 000000 XP
Controller
ViewModel
+1 XP
New level has been unlocked
Level #2
Installing Rails
score: 000001 XP
Windows:
@RailsInstaller provide package included all what you need to start your first project with
Rails ( http://railsinstaller.org )
Linux&Mac:
You can install Rails with RVM (Ruby version manager) with a simple two commands:
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ curl -sSL https://get.rvm.io | bash -s stable --rails
+1 XP
New level has been unlocked
Level #2
Build your first app
score: 000002 XP
You can create a new app called (blog) by running the following
CMD:
$ rails new blog
Now we need to change the directory to our Rails App
$ cd blog
start the rails server by running
$ rails s
You can find your app on the following link below:
$ http://localhost:3000
+1 XP
New level has been unlocked
score: 000003 XP
You can create a new app called (blog) by running the following
CMD:
$ rails new blog
Now we need to change the directory to our Rails App
$ cd blog
start the rails server by running
$ rails s
You can find your app on the following link below:
$ http://localhost:3000
+1 XP
New level has been unlocked
Level #3
Start Scaffolding now
score: 000004 XP
So to make it easier creating CRUD system there is something
called scaffolding, rails have the philosophy of DRY so this
will save your time
$ rails generate scaffold post title:string content:text picture:string
Each time you create a model in rails you should migrate your
datebase with:
$ rake db:migrate
Now check your posts page in your browesr in the following
link:
$ http://localhost:3000/posts
+2 XP
New level has been unlocked
Level #4
Upload Pictures
score: 000006 XP
Firstable lets Open up the Gemfile wish is located in the root
directory of your app and add this line:
gem 'carrierwave'
Then install the Carrierwave gem:
$ bundle install
After installing the Carrierwave gem now you should create your
first Uploader, this will create picture_uploader.rb file in
app/uploaders
$ rails generate uploader Picture
score: 000006 XP
Then lets mount our uploader to the Poste Modele
app/models/poste.rb
mount_uploader :picture, PostUploader
Then lets mount our uploader to the Poste Modele
app/models/poste.rb
mount_uploader :picture, PostUploader
Now we should update our poste form
<%= f.text_field :picture %>
<%= f.file_field :picture %>
And we should update the show page also
<%= image_tag(@post.picture_url, :width => 600) if @poste.picture.present? %
:picture
+2 XP
New level has been unlocked
Level #5
Create Static Pages
score: 000008 XP
If you want to create a static page you can do it by creating a
controller with the corresponding view
$ rails generate controller pages about
Now you can visit your page through
$ http://localhost:3000/pages/about
Open up the view file corresponding to the pages#about
controller and add some info there
app/views/pages/about.html.erb
+1 XP
New level has been unlocked
Level #6
Bling Bling Baby
score: 000008 XP
Its all up to you to tweek your css file, wich is located in
the following path:
app/assets/stylesheets/application.css
If you are planning to use bootstrap so make sure you add
bootstrap to your Gemfile
gem 'bootstrap-sass', '~> 3.3.6'
Now Import bootstarp to your main application css
app/assets/stylesheets/application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
+1 XP
New level has been unlocked
Level #7
Make some serious relations
score: 000009 XP
Create a comment scaffold, with the commentator name, the
comment body (contents of the comment) and with the reference
to the ideas table (post_id).
$ rails g scaffold comment user_name:string body:text post_id:integer
Then migrate your datebase:
rake db:migrate
Openup poste model File app/models/post.rb and add
has_many :comments
score: 000009 XP
And from the comment side add
belongs_to :post
And from the comment side add
<h3>Comments</h3>
<% @comments.each do |comment| %>
<div>
<strong><%= comment.user_name %></strong>
<br />
<p><%= comment.body %></p>
<p><%= link_to 'Delete', comment_path(comment), method: :delete, data: { confirm: 'Are you
sure?' } %></p>
</div>
<% end %>
<%= render 'comments/form' %>
score: 000009 XP
Lets modifier the app/controllers/ideas_controller.rb to get
fit with what we did in the previously changes
@comments = @idea.comments.all
@comment = @idea.comments.build
And also add the following line
app/views/comments/_form.html.erb
<%= f.hidden_field :idea_id %>
Congratulation!!
you finished all the levels
of the game
With 10 XP
Now you are ready for another levels
of the game but you need extra life points !!
So follow us on
Facebook Group Rails on Algeria
FB: El Orabi Mohamed Ikbal ikbalix@gmail.com

More Related Content

What's hot

Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
How to dockerize rails application compose and rails tutorial
How to dockerize rails application compose and rails tutorialHow to dockerize rails application compose and rails tutorial
How to dockerize rails application compose and rails tutorialKaty Slemon
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In DepthKirk Bushell
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoRyan Weaver
 
Getting Started with WP-CLI
Getting Started with WP-CLIGetting Started with WP-CLI
Getting Started with WP-CLIChristian Nolen
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroChristopher Pecoraro
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginnerUmair Amjad
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to LaravelEli Wheaton
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkEdureka!
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayEdureka!
 
Weblogic as a windows service
Weblogic as a windows serviceWeblogic as a windows service
Weblogic as a windows serviceRavi Kumar Lanke
 
Enterprising JavaFX
Enterprising JavaFXEnterprising JavaFX
Enterprising JavaFXRichard Bair
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingChristopher Pecoraro
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppEdureka!
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPressLester Chan
 

What's hot (20)

Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
How to dockerize rails application compose and rails tutorial
How to dockerize rails application compose and rails tutorialHow to dockerize rails application compose and rails tutorial
How to dockerize rails application compose and rails tutorial
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Rack
RackRack
Rack
 
Webpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
 
Mule velocity
Mule velocityMule velocity
Mule velocity
 
Getting Started with WP-CLI
Getting Started with WP-CLIGetting Started with WP-CLI
Getting Started with WP-CLI
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginner
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to Laravel
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
 
Slim3 quick start
Slim3 quick startSlim3 quick start
Slim3 quick start
 
NodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin WayNodeJS : Communication and Round Robin Way
NodeJS : Communication and Round Robin Way
 
Javascript laravel's friend
Javascript laravel's friendJavascript laravel's friend
Javascript laravel's friend
 
Weblogic as a windows service
Weblogic as a windows serviceWeblogic as a windows service
Weblogic as a windows service
 
Enterprising JavaFX
Enterprising JavaFXEnterprising JavaFX
Enterprising JavaFX
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routing
 
Node JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web AppNode JS Express : Steps to Create Restful Web App
Node JS Express : Steps to Create Restful Web App
 
Laravel Eloquent ORM
Laravel Eloquent ORMLaravel Eloquent ORM
Laravel Eloquent ORM
 
Developing Plugins For WordPress
Developing Plugins For WordPressDeveloping Plugins For WordPress
Developing Plugins For WordPress
 

Similar to Ruby On Rails Starter Kit

Guide - Migrating from Heroku to AWS using CloudFormation
Guide - Migrating from Heroku to AWS using CloudFormationGuide - Migrating from Heroku to AWS using CloudFormation
Guide - Migrating from Heroku to AWS using CloudFormationRob Linton
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Railsanides
 
All girlhacknight intro to rails
All girlhacknight intro to railsAll girlhacknight intro to rails
All girlhacknight intro to railsNola Stowe
 
Rails
RailsRails
RailsSHC
 
Gigigo Rails Workshop
Gigigo Rails WorkshopGigigo Rails Workshop
Gigigo Rails WorkshopAlex Rupérez
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Dilouar Hossain
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortegaarman o
 
Create rails project
Create rails projectCreate rails project
Create rails projectAlain Bindele
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发shaokun
 

Similar to Ruby On Rails Starter Kit (20)

ragi_tutorial_v1
ragi_tutorial_v1ragi_tutorial_v1
ragi_tutorial_v1
 
ragi_tutorial_v1
ragi_tutorial_v1ragi_tutorial_v1
ragi_tutorial_v1
 
Guide - Migrating from Heroku to AWS using CloudFormation
Guide - Migrating from Heroku to AWS using CloudFormationGuide - Migrating from Heroku to AWS using CloudFormation
Guide - Migrating from Heroku to AWS using CloudFormation
 
Ruby Rails Web Development.pdf
Ruby Rails Web Development.pdfRuby Rails Web Development.pdf
Ruby Rails Web Development.pdf
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Create a new project in ROR
Create a new project in RORCreate a new project in ROR
Create a new project in ROR
 
All girlhacknight intro to rails
All girlhacknight intro to railsAll girlhacknight intro to rails
All girlhacknight intro to rails
 
Rails
RailsRails
Rails
 
Gigigo Rails Workshop
Gigigo Rails WorkshopGigigo Rails Workshop
Gigigo Rails Workshop
 
Rspec
RspecRspec
Rspec
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
RoR guide_p1
RoR guide_p1RoR guide_p1
RoR guide_p1
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Introduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman OrtegaIntroduction to Rails - presented by Arman Ortega
Introduction to Rails - presented by Arman Ortega
 
rails.html
rails.htmlrails.html
rails.html
 
rails.html
rails.htmlrails.html
rails.html
 
Lampstack (1)
Lampstack (1)Lampstack (1)
Lampstack (1)
 
Create rails project
Create rails projectCreate rails project
Create rails project
 
Rails web api 开发
Rails web api 开发Rails web api 开发
Rails web api 开发
 
Top 8 Ruby on Rails Gems
Top 8 Ruby on Rails GemsTop 8 Ruby on Rails Gems
Top 8 Ruby on Rails Gems
 

Recently uploaded

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 

Recently uploaded (20)

SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 

Ruby On Rails Starter Kit

  • 1. Start Ruby On Rails Starter KIT score: 000000 XP
  • 3. score: 000000 XP What is ruby? Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed in the mid-1990s by Yukihiro "Matz" Matsumoto in Japan. Matsumoto has said that Ruby is designed for programmer productivity and fun, following the principles of good user interface design What is rails? Ruby on Rails, or simply Rails, is a web application framework written in Ruby under MIT License. Rails is a model–view–controller (MVC) framework, providing default structures for a database, a web service, and web pages.
  • 5. +1 XP New level has been unlocked
  • 7. score: 000001 XP Windows: @RailsInstaller provide package included all what you need to start your first project with Rails ( http://railsinstaller.org ) Linux&Mac: You can install Rails with RVM (Ruby version manager) with a simple two commands: $ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 $ curl -sSL https://get.rvm.io | bash -s stable --rails
  • 8. +1 XP New level has been unlocked
  • 10. score: 000002 XP You can create a new app called (blog) by running the following CMD: $ rails new blog Now we need to change the directory to our Rails App $ cd blog start the rails server by running $ rails s You can find your app on the following link below: $ http://localhost:3000
  • 11. +1 XP New level has been unlocked
  • 12. score: 000003 XP You can create a new app called (blog) by running the following CMD: $ rails new blog Now we need to change the directory to our Rails App $ cd blog start the rails server by running $ rails s You can find your app on the following link below: $ http://localhost:3000
  • 13. +1 XP New level has been unlocked
  • 15. score: 000004 XP So to make it easier creating CRUD system there is something called scaffolding, rails have the philosophy of DRY so this will save your time $ rails generate scaffold post title:string content:text picture:string Each time you create a model in rails you should migrate your datebase with: $ rake db:migrate Now check your posts page in your browesr in the following link: $ http://localhost:3000/posts
  • 16. +2 XP New level has been unlocked
  • 18. score: 000006 XP Firstable lets Open up the Gemfile wish is located in the root directory of your app and add this line: gem 'carrierwave' Then install the Carrierwave gem: $ bundle install After installing the Carrierwave gem now you should create your first Uploader, this will create picture_uploader.rb file in app/uploaders $ rails generate uploader Picture
  • 19. score: 000006 XP Then lets mount our uploader to the Poste Modele app/models/poste.rb mount_uploader :picture, PostUploader Then lets mount our uploader to the Poste Modele app/models/poste.rb mount_uploader :picture, PostUploader Now we should update our poste form <%= f.text_field :picture %> <%= f.file_field :picture %> And we should update the show page also <%= image_tag(@post.picture_url, :width => 600) if @poste.picture.present? % :picture
  • 20. +2 XP New level has been unlocked
  • 22. score: 000008 XP If you want to create a static page you can do it by creating a controller with the corresponding view $ rails generate controller pages about Now you can visit your page through $ http://localhost:3000/pages/about Open up the view file corresponding to the pages#about controller and add some info there app/views/pages/about.html.erb
  • 23. +1 XP New level has been unlocked
  • 25. score: 000008 XP Its all up to you to tweek your css file, wich is located in the following path: app/assets/stylesheets/application.css If you are planning to use bootstrap so make sure you add bootstrap to your Gemfile gem 'bootstrap-sass', '~> 3.3.6' Now Import bootstarp to your main application css app/assets/stylesheets/application.scss @import "bootstrap-sprockets"; @import "bootstrap";
  • 26. +1 XP New level has been unlocked
  • 27. Level #7 Make some serious relations
  • 28. score: 000009 XP Create a comment scaffold, with the commentator name, the comment body (contents of the comment) and with the reference to the ideas table (post_id). $ rails g scaffold comment user_name:string body:text post_id:integer Then migrate your datebase: rake db:migrate Openup poste model File app/models/post.rb and add has_many :comments
  • 29. score: 000009 XP And from the comment side add belongs_to :post And from the comment side add <h3>Comments</h3> <% @comments.each do |comment| %> <div> <strong><%= comment.user_name %></strong> <br /> <p><%= comment.body %></p> <p><%= link_to 'Delete', comment_path(comment), method: :delete, data: { confirm: 'Are you sure?' } %></p> </div> <% end %> <%= render 'comments/form' %>
  • 30. score: 000009 XP Lets modifier the app/controllers/ideas_controller.rb to get fit with what we did in the previously changes @comments = @idea.comments.all @comment = @idea.comments.build And also add the following line app/views/comments/_form.html.erb <%= f.hidden_field :idea_id %>
  • 31. Congratulation!! you finished all the levels of the game With 10 XP
  • 32. Now you are ready for another levels of the game but you need extra life points !!
  • 33. So follow us on Facebook Group Rails on Algeria FB: El Orabi Mohamed Ikbal ikbalix@gmail.com