Ruby On Rails is a Ruby-based Web development framework.
Ruby is an object-oriented scripting programming language.
2.Ruby has the following advantages:
Explanation-based implementation, convenient and quick
Ruby is the interpreted language, its procedures can be executed without the compiler.
Grammar is simple, elegant
Grammar is relatively simple, similar to Algol grammar grades.
Completely object-oriented
Ruby from the outset was designed to pure object-oriented language, so everything is an object, such as integers and other basic data types.
Regular engine built for text processing
Supporting Ruby powerful string handling and regular expression search function, it will be convenient to deal with string.
Automatic garbage collection
With garbage collection (Garbage Collect, GC) function, can automatically target of recycling no longer used. Does not require users to manage memory.
And a high degree of cross-platform portability
Ruby supports multiple platforms, in Windows, Unix, Linux, MacOS can run on. Ruby is very good portability procedures, the vast majority of programs can not modify them in a variety of platforms running on.
Has elegant, sophisticated exception handling mechanism
Ruby provides a set of exception handling mechanisms, can easily deal with the code gracefully handle errors.
Has many advanced features
Ruby has many advanced features, such as operator overloading, Mix-ins, special methods and so on, are using these features can easily complete a variety of powerful functions.
At the same time, because it is to interpret language, Ruby also has the following disadvantage:
Interpreted language, so slow
Less static checks
3. Necessary software
(1) Automatic installation of Ruby language 1.8.4RC1 operating environment (including tools such as RubyGems) software
(2) download the software: Click here to double-click the file: ruby184-16_rc1.exe default will be installed in the directory c: \ ruby next, but we put it to install in the directory c: \ rubyr1.8.4 under
(3) Rails framework for the installation: Change directory to $ RAILS_HOME / ruby / bin under the
gem install rails -r -y
(4) the installation of database-driven
Change directory to $ RAILS_HOME / ruby / bin under the
Executive
gem install postgres-pr
(5) in order to facilitate the development could be $ RAILS_HOME / ruby / bin added to the system PATH variable go
4. To develop a simple user management system
(1) create a procedural framework
rails catsystem will generate cat directory, cat directory structure in Figure
app store program code
config configuration file stored
log storage server logs
(2) See the operation
ruby script\server
WEBrisk is a Ruby based on the WebServer
(3) visit to view the operation of
Using IE to visit
http://localhost:3000
(4) modify configuration files
Config/database.yml
Yml: ruby world standard configuration file format
Property: [space] value
Note: YML at the grammar, the property: the back of the "space" must be
(5) database configuration information
Development: Development phase
Test: Testing the use of
Production: the use of the deployment phase
(6) create a database
Createdb-E UNICODE rubydemo
(7) revised config / database.yml file
development: adapter: postgresql database: rubydemo username: postgres password: postgresql host: 192.168.1.223 port: 5432 encoding: UTF8 test: adapter: postgresql database: rubydemo username: postgres password: postgresql host: 192.168.1.223 port: 5432 encoding: UTF8 production: adapter: postgresql database: rubydemo username: postgres password: postgresql host: 192.168.1.223 port: 5432 encoding: UTF8
(8) create a database table
drop sequence seq_user_accounts_id;
drop table user_accounts;
create sequence seq_user_accounts_id;
create table user_accounts(
id integer default nextval('seq_user_accounts_id') primary key,
login_name varchar(64),
login_password varchar(64),
email varchar(64)
) must have id field The need for the plural
(9) to build table
psql rubydemo \i postgresql.sql
(10) to create model and controller
ruby script/generate scaffold UserAccount UserManager
Scaffold is a code generation RoR framework
Useraccount on behalf of user_accounts Table
UserManager express controller name
(11) run
ruby script/server
http://localhost:3000/user_manager/newview it.








Responses to “Ruby On Rails (1) hellowolrd”