• Save
Viridians on Rails
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Viridians on Rails

on

  • 726 views

Ruby on Rails KT for any new joiner.

Ruby on Rails KT for any new joiner.

Statistics

Views

Total Views
726
Views on SlideShare
647
Embed Views
79

Actions

Likes
0
Downloads
0
Comments
0

5 Embeds 79

http://viridian.in 65
http://viridians.org 11
http://localhost:3000 1
http://www.slideshare.net 1
http://viridians.blogspot.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Ramesh - Vista
  • Start -> Run -> cmd > cd C: <br /> ubyonrails > use_ruby > cd C: <br /> ubyonrails <br /> ails_apps > rails project_name -d mysql &lt;>/ ..../app ......../controller -> A controller handles a web request from the user. ......../helpers -> Functions which help GUI mainly. ......../models -> Each file corresponds to a table in database. ......../views ............../layouts -> template of view files. ............../ -> folder corresponding to each controller. ................../viewfiles.html.erb -> Run it through ruby interpreteur and generate html file. A view file corresponding to each function in a controller. ..../config ......../environments -> Holds 3 configuration files one each for production, test and development env. ......../initializers -> Constants. ......../environment file -> General configuration. ......../database.yml file -> Database connection configuration per environment (prod, test, dev). ......../routes file -> Routing of incoming web requests to appropriate code. ..../db ......../migrate -> Holds migration files to creata tables, upload data, upload test data, etc. (like SQL scripts) ......../seed ............../always -> yml files for reference data. ............../before_others -> Holds yml files needed to be run always first. ......../schema.rb -> Holds database table structures. Rails automatically creates it. Never manually change it. ......../seeds.rb -> ignore. ..../doc -> RubyDocs. Ignore not important ..../lib -> ignore ..../log -> ignore ..../public ......../images -> Holds pictures that are to be shown on website. ......../javascript -> Javascript. ......../stylesheets -> CSS. ..../private -> Does not come with rails but at Viridians we add this folder to store user images and files. The public folder is exposed and hence a security risk. ..../script -> Scripts to create, manage and launch various rails services. ..../test -> ignore ..../tmp -> ignore ..../vendor ......../plugins -> 3rd party Plugins used by the project. ......../gems -> Holds 3rd party gems which have been frozen. README-> ignore Rakefile-> ignore
  • Start MYSQL Server   > cd project_name > ruby script/server => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server   Go to browser and type http://localhost:3000/
  • > ruby scriptgenerate scaffold contact name:string weblink:string email:string password:string -> Creates contacts_controller with new, create, edit, update, delete, show, index methods. Contacts model and contacts view folder with new, edit, show, index view files. Links accessible are http://website.com/contacts/new http://website.com/contacts/edit/1 http://website.com/contacts/show/1 http://website.com/contacts/index   > ruby scriptgenerate controller password -> Rails promotes creating restful design. Now considering, we need to create 3 functions, edit_password, forgot_password, create_random_password. Instead of adding them to contacts controller, create a dummy controller called passwords and dump these functions in the passwords controller.   > ruby scriptgenerate model page name:string header_str:string -> Creates a model file alone / table.   rake db:drop -> Drop database schema   rake db:create -> Add database schema   rake db:migrate RAILS_ENV=production VERSION=&lt;&lt;>> -> Create tables and upload datavalues based on db/migrations files   > ruby script/server => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server
  • rake db:drop -> Drop database schema rake db:create -> Add database schema  rake db:migrate RAILS_ENV=production VERSION=&lt;&lt;>> -> Create tables and upload datavalues based on db/migrations files   > ruby script/server => Booting Mongrel => Rails 2.3.2 application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server
  • Sessions in Rails Sessions configuration at …configinitializerssession_store.rb ActionController::Base.session = { :key => &apos;_blabla&apos;, :secret => ‘….‘} ActionController::Base.session_store = :active_record_store Store session in DB at …dbmigratecreate_tables.rb  sessions table Some functions at …appcontrollersapplication_controller.rb current_user_session, current_user, require_user, require_no_user Methods in Models User Model Virtual attributes on object def name return first_name + last_name end Static Methods def self.randomize_username …. End Database queries User.find_by_first_name(‘Vikram’) User.all(:conditions => {:first_name => ‘Vikram’, :last_name => ‘Aditya’}, :order => “created_at DESC”) User.first(:conditions => {:first_name => ‘Vikram’})

Viridians on Rails Presentation Transcript

  • 1. on Why Rails? How Rails? Please find latest version of the presentation at http://viridian.in/academic_platform
  • 2. Web World
    • What is a website?
      • Content available remotely over a browser.
    • What is a web application?
    • Create Retrieve Update Delete (CRUD) operations on content designed for a purpose.
    • What is an enterprise application?
    • Applications / IT that augments business for an organization.
    • What is SAAS?
    • Packaging enterprise applications as web apps.
  • 3. Software as a Service
    • Why SAAS?
      • Entry cost is low: Don’t care to maintain server and for that matter IT staff.
      • Don’t care OS.
      • Don’t care programming language and database application.
      • Don’t care how much hard disk space.
      • Don’t care where I work from.
    • Why not SAAS?
      • Data is business and your data on someone else's server - Can I trust?
      • Portability - Can I move out and still function safely?  Port out and port in data
      • Security! security! security!  
      • How much can I customize it?  Provide customization for client to play with.
      • Integration with other applications?  WEB API
    • SAAS != Rocket Science
      • But useful only if we can support complex business logic, and write complex code to counter the WHY NOT SAAS complications.
  • 4. Why Rails?
    • Convention (Rails) versus Configuration (Java).
    • Model View Controller (MVC) architecture.
    • Don't Repeat yourself (Reuse).
    • Agile Methodology (Rails) versus SDLC (Java).
    • Based on Ruby -> OOL, Interpreted Lang, Simple, Intuitive, Reflective (pass code as string and make it run), Command line support, etc.
    • Hottest technologies supported: Ajax, Jquery, CSS, Oracle, MySQL, SQLLite, RESTful, APIs, XML, JSON, Web APIs, etc.
    • Database independent applications.
    • Open Source. Good support from a growing community.
    • No need for heavy IDEs.
    • Lots of behind the scene magic: Modes of operation: development, test, production, In built caching, testing, data migration support.
  • 5. Why is Rails difficult to learn?
    • Because it is a shift in paradigm
    • Individuals and interaction over processes and tools
    • Agile over SDLC
    • Working software over comprehensive documentation
    • Interpreted language over c ompile language
    • Customer collaboration over contract negotiation
    • Responding to change over following a plan
    • C onstraints ( Rails) over flexibility (Java )
  • 6. But the question still remains…
    • “ Rails reduces our entry cost to SAAS”.
    • We want to build highly commoditized simple to use SAAS products which solve complex business problems at a low cost for social causes.
      • Don’t want to repeat ourselves / reinvent wheel.
      • Believe in setting a convention to achieve efficiency.
      • Believe in BEST OF ALL WORLDS approach through open source APIs / projects.
      • We want to share, work together and grow together.
      • Want to reduce focus on technicalities and increase focus on complex business logic and getting products production ready.
    Whose using Rails? … why is Viridians on Rails?
  • 7. LEARNING TO LEARN RAILS YOURSELF Rails is based on conventions. To start, you need to know the basics. But from then on, learning rails is all about self-experimenting, Googling and discovering new conventions / plugins / gems / open source APIs which solve or simplify your problems.
  • 8. Dev. environment
    • Window XP / 32 bit machines: MySQL (32 bit), Ruby 1.8.7, Rails 2.3.4, Mongreal Server, Scite text editor
    • If you work on Vista, contact us.
    • Download (209 MB) our drag drop environment from http://jump.fm/UNRAN
    • Unzip contents into folder: C: ubyonrails
    • Double Click and open Instant Rails
    • It will give error that apache not working. Its fine press OK and continue.
  • 9. Rails project Note: Gem is the ruby equivalent of Java jar. Plugin is nothing but an unpacked jar file. Gem code cannot be changed but plugin code can be changed.
  • 10. Is my env. working fine? *Note: 127.0.0.1 is localhost by default in Windows
  • 11. Getting started… Types of methods for Models: - Virtual Attributes - Static Methods
  • 12. Rails Magic in MVC terms (Gem) (Gem) (Gem)
  • 13.
    • Rake (Ruby Make) is a build tool. Uses:
      • Pulling a list of members to send out an email.
      • Doing nightly data calculations and reporting.
      • Expiring and regenerating caches.
      • Making backups of my database and subversion repository.
      • Running any sort of data manipulation script.
      • Create and delete databases, tables and reference data.
      • Learn more at http://railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial
    • Migrations in Viridians projects
      • Add those yml files which need to be uploaded
      • before others in the before_others folder.
      • rake db:always is a rake task to load the data from
      • the yaml files located in db/seed/always. It deletes
      • the existing records in those corresponding tables
      • and recreates them.
    Migrations & Rake Check your application at http://localhost:3000/contacts/
  • 14. Other basics
    • Sessions in Rails
      • Sessions configuration at …configinitializerssession_store.rb
      • Store session in DB at …dbmigratecreate_tables.rb  sessions table
      • Some functions at …appcontrollersapplication_controller.rb
    • Database queries
    • Validations
  • 15. GIT Version Control
    • Evolution of open source version controls: CVS  SVN  GIT
    • Features:
    • 1. Distributed Repositories
    • 2. Non Linear Development
    • 3. Branching, Merging
    • 4. Cryptic Authentication
    • Download: http://git-scm.com
    • Even most open source rails projects are on a social coding website called as http://github.com
    • Viridians wants to use GIT to manage code as technologists spread across countries code on the same projects.
    • Presently we are developing capability to set up a GIT Server, and master and possibly simplify usage of GIT. Once, its done, we will issue a detailed KT and installation to all.
  • 16. Your friends
    • Your first rails project: http://media.rubyonrails.org/video/rails_blog_2.mov
    • Online books: http://www.railstutorial.org/book
    • One of the best way to learn a new language is to see real projects and the code in use. http://github.com/ is the defacto social coding website used by most open source Rails projects, plugins, gems, etc. If you want to use a plugin and need a example of how to use it, Github even allows to search for code.
    • Screencasting has been core to the Rails community. Some well known video tutorials sites are: http://railscasts.com , http://www.teachmetocode.com/ , http://rubyplus.org/
    • Official Sources: http://guides.rubyonrails.org/ (concepts), http://api.rubyonrails.org/ (API documentation), http://railsapi.com/doc/rails-v2.3.5/ (easier to use api documentation)
    • Ask the group: http://groups.google.com/group/rubyonrails-talk
    • Test your CSS for all browsers http://www.my-debugbar.com/wiki/IETester/HomePage
  • 17. Ritvvij Parrikh http://viridian.in [email_address] http://groups.google.com/group/viridian_in Thank You! Create a Viridians account at http://my.viridian.in