Ruby rails Note 1

Source: Internet
Author: User
Tags ruby on rails

I recently started to read the Good Book Ruby on Rails developed by instructor Li Gang. It is a very good book and notes. I didn't use rails 2. 0, only use
Rails 1.2.6.

1) install rails 1.2.6
Because it is used on the network
Gem install rails -- remote will press 2. 0 version, do not like it, so
Related 1 is downloaded online. 2. Install Package 6
Http://rubyforge.org/frs? Group_id = 307 download rails (I downloaded version 1.2.6 );
Http://rubyforge.org/projects/activesupport to download activesupport (I downloaded version 1.4.4 );
Http://rubyforge.org/projects/activerecord/ to download activerecord (I downloaded version 1.15.6 );
Http://rubyforge.org/projects/actionpack to download actionpack (I downloaded version 1.13.6 );
Http://rubyforge.org/projects/actionmailer to download actionmailer (I downloaded version 1.3.6 );
Http://rubyforge.org/projects/aws to download actionwebservice (I downloaded version 1.2.6 );
Http://rubyforge.org/projects/rake to download Rake (I downloaded version 0.8.1 );
All the above downloaded files include zip and gem;
Install later
D: \ rails> gem install activesupport-1.4.4.gem (equivalent effect of D: \ rails> gem install activesupport-V 1.4.4)
Successfully installed activesupport, version 1.4.4
Installing Ri documentation for activesupport-1.4.4...
Installing rdoc documentation for activesupport-1.4.4...
 
D: \ rails> gem install activerecord-1.15.6.gem
Successfully installed activerecord, version 1.15.6
Installing Ri documentation for activerecord-1.15.6...
Installing rdoc documentation for activerecord-1.15.6...
 
D: \ rails> gem install actionpack-1.13.6.gem
Successfully installed actionpack, version 1.13.6
Installing Ri documentation for actionpack-1.13.6...
Installing rdoc documentation for actionpack-1.13.6 ..
 
D: \ rails> gem install actionmailer-1.3.6.gem
Successfully installed actionmailer, version 1.3.6
Installing Ri documentation for actionmailer-1.3.6...
Installing rdoc documentation for actionmailer-1.3.6...
 
D: \ rails> gem install actionwebservice-1.2.6.gem
Successfully installed actionwebservice, version 1.2.6
Installing Ri documentation for actionwebservice-1.2.6...
Installing rdoc documentation for actionwebservice-1.2.6...
 
D: \ rails> gem install rake-0.8.1.gem
Successfully installed rake, version 0.8.1
Installing Ri documentation for rake-0.8.1...
Installing rdoc documentation for rake-0.8.1...

D: \ rails> gem install rails-1.2.6.gem
Successfully installed rails, version 1.2.6

The installation process has ended. You can check the environment:
D: \ rails> rails
Usage: D:/rails/Ruby/bin/rails/path/to/Your/APP [Options]
Options:
 
Running rails-V displays the version number, indicating that the installation is successful.

2) create an application: rails firstapp
3) Start the server. Be sure to go to The firstapp directory, use Ruby script/server, and then use localhost: 3000. You can change the port.
Ruby script/serve-P 3002
4) change the database. yml file in the config directory to MySQL
Development:
Adapter: MySQL
Database: firstapp_development
Username: Root
Password: 123456
Port: 3306
HOST: localhost
5) generate control layer and model layer
Ruby script \ generate scaffold model name (Controller name)
6) Chinese problem (I used the connection encoding in phpMyAdmin 2.7, MySQL 5, and mysql5 my. ini using GBK)
A to create a table, such as to display Chinese fields or tables, collate with gbk-2312
In database B. yml, add the encoding: utf8
The C page is saved and edited (I use DW 8) with UTF-8 encoding. Otherwise, garbled characters are displayed on the page.
D. Add
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
E. In Applicaion. Rb under the config directory, add
Def set_charset
@ Headers ["Content-Type"] = "text/html; charset = UTF-8"
@ Response. headers ["Content-Type"] = "text/html; charset = UTF-8"
Suppress (activerecord: statementinvalid) Do
Activerecord: base.connection.exe cute 'set names UTF-8'
End
End

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.