开发者

What are the components of Ruby on Rails that I need to understand?

开发者 https://www.devze.com 2023-01-08 16:59 出处:网络
I\'ve been going through this online rails tutorial: http://www.railstutorial.org/ I highly recommend it if you want to get an overview of what rails do and some best practice methods.

I've been going through this online rails tutorial: http://www.railstutorial.org/ I highly recommend it if you want to get an overview of what rails do and some best practice methods.

But now, as I do my first application, I am having trouble isolating parts of Rails that I need to understand and learn. My question is: What are the components of rails that I need to understand to be competent? If you could point out where the resources are, that would be much appreciated also.

This is a rough idea of what I expect I need to know:

  • Basic Ruby
  • Model View Controller architecture (MVC)
  • Object Orientated Programming
  • Plugins
  • Tools like Rake
  • A test driven framework (rspec?)
  • Rails conf开发者_开发问答ig
  • Rails scripts (generate etc)
  • How to deploy
  • The API
  • Where the documentation is (and good resources)
  • Agile methodology

This assumes that I am an experienced developer and I have my development environment set up and can do a basic hello world application


Below are the basic Rails components(gems -- not dependencies and libraries)

ActiveSupport is a compatibility library including methods that aren't necessarily specific to Rails. You'll see ActiveSupport used by non-Rails libraries because it contains such a lot of useful baseline functionality. ActiveSupport includes methods like how Rails changes words from single to plural, or CamelCase to snake_case. It also includes significantly better time and date support than the Ruby standard library.

ActiveModel hooks into features of your models that aren't really about the database - for instance, if you want a URL for a given model, ActiveModel helps you there. It's a thin wrapper around many different ActiveModel implementations to tell Rails how to use them. Most commonly, ActiveModel implementations are ORMs (see ActiveRecord, below), but they can also use non-relational storage like MongoDB, Redis, Memcached or even just local machine memory.

ActiveRecord is an Object-Relational Mapper (ORM). That means that it maps between Ruby objects and tables in a SQL database. When you query from or write to the SQL 19database in Rails, you do it through ActiveRecord.
ActiveRecord also implements ActiveModel. ActiveRecord supports MySQL and SQLite, plus JDBC, Oracle, PostgreSQL and many others.

ActionPack does routing - the mapping of an incoming URL to a controller and action in Rails. It also sets up your controllers and views, and shepherds a request through its controller action and then through rendering the view. For some of it, ActionPack uses Rack. The template rendering itself is done through an external gem like Erubis for .erb templates, or Haml for .haml templates. ActionPack also handles action- or view-centered functionality like view caching.

ActionMailer is used to send out email, especially email based on templates. It works a lot like you'd hope Rails email would, with controllers, actions and "views" - which for email are text- based templates, not regular web-page templates.

A standard Rails application depends on several gems, specifically:

abstract

actionmailer

actionpack

activemodel

activerecord

activesupport

arel

builder

bundler

erubis

i18n

mail

mime-types

polyglot

rack

rack-cache

rack-mount

rack-test

rails

railties

rake

sqlite3-ruby

thor

treetop

tzinfo


Some things that spring to mind...

  • Logging and debugging techniques
  • Routing and RESTful controllers
  • Generators and scaffolding
  • Testing and fixtures/factories (eg Test::Unit, RSpec, Shoulda/FactoryGirl)
  • Common plugins/gems like auth logic and cancan (see Most useful Rails plugins, Ruby libraries and Ruby gems?)

A good IDE/editor is useful, common ones are TextMate (with bundles), Aptana RadRails, and Vim (with plugins).

Definitely check out Ryan Bates' awesome screencasts and http://railscasts.com/


In rails, the main components to be noticed are as:

  1. configuration for your app
  2. gems with a specific version, required for your app(available at rubygems.org)
  3. routes information for your app
  4. scaffolding and generators in your app
  5. three different environments for your app, as Development, Testing, Production
  6. testing strategies for your app, like unit tests, functional tests
  7. Databases settings for your different-2 environments, and database engines like SQLite, MySQL, Postgres
  8. server to run your app
  9. management of your assets in app/assets folder
  10. Methods to deploy your app and much more......

In addition, You should go through these slides

and this page also contains a lot of info for important rails components.

0

精彩评论

暂无评论...
验证码 换一张
取 消