Recently, rake was used for database migration. Ruby's activerecord only supports single-primary-key tables, which is very troublesome for the migration of compound-key tables.Assume that table A1 has a Sid primary key, and its storage is as follows:
The scripts written in Ruby run faster, and you decided to use ruby.
Compared with my e-commerce website, I have the opportunity to use it: Get all URLs on a page.
Save the following script as URLScan. RB. Usage: run the CMD command to enter the
# Part One Afile = file.
New ("C: \ 1.txt"," W ")
Afile. Puts "The 1"
Afile. Puts "The 2"
Afile. Close
# Part Two
Afile = file.
New ("C: \ 2.txt"," W ")
Puts "The 1"
Puts "The 2"
Afile. Close
I'm bored and have a look at how Ruby reads and
1. syntax check (-C)
Execute IN RUBYProgramWhen using the "-c" command, the Ruby interpreter does not execute the program, but checks whether the program is to be executed.CodeCorrectness
Ruby-C eg. Rb
2. Enable warning (-W)
Run the program with
Block, lambda, and proc are important in ruby.
A block is an anonymous function. It is called using a field in the called method. Block is mainly used for iteration.
RubyCode:
Arr = [1, 2, 4, 5]Arr. Each {| item | puts item}
Ruby Study Notes (1) Abstract: I found a good place to learn Ruby. I try to spend some time learning every day. Read the full text
Ruby Study Notes (2) Abstract: This lesson contains a lot of content. Read the full text.
Ruby Study Notes (3)
In addition to class, Ruby also supports module, which has two functions:1. namespace used as a group method and constant to prevent name conflicts2. Mixin classes can be mixed in. Instances of Mixin module classes have module methods.
If
Today I learned about the closure of Ruby. I mainly read the book "metapromgramming ruby:
Http://book.douban.com/subject/4086938/
In chapter 3, the closed boss at the end of the closure is a question: write your first domain-specific language.
event
Preface
Today, when giving a lecture, Mr. Jiang talked about the development concept of Ruby on Rails, that is, happy programming. It is a pleasure to write code.
In the world of study, I don't feel how happy I am. I just don't have to go to work.
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 #! /Usr/bin/ENV Ruby
2
3 class megagreeter
4 attr_accessor: names // sets attributes. Two methods (name, name =) are automatically generated to
1
Check whether the entered content is empty.
In Models
Validates_presence_of: title,: Description,: image_url
2
Verify that the entered content is Numeric
How to interview Ruby/rails Daniel by YuanYi | published: July 28,200 8
The Internet has no threshold for reporters. Anyone who wants to become a network reporter, especially a network technology reporter, even does not need to meet the interviewer.
# Class describ ------ rdoc rules# = Headers# This is header content#== Sub Header# This is sub header content#=== Sub Header# This is sub HeaderClass animalAttr_accessor: name # ------------- ① # This is the comment for the 'new' method! Def
$res = "__"def lamb(&lamb)3.times do puts $res=lamb.call end puts "-------at the end of lamb() : #{$res}"enddef lamb_test lamb { return puts " return in lamb() " } puts "--------at the lamb_test() end"enddef bl3.times do puts $res=
I have no intention of initiating a language dispute. I just want to talk about my own ideas.
I have also studied Ruby. I feel that it is too complicated, with too many syntaxes, too much sugar, and too many abbreviations.
I haven't played Ruby for
1. Constants
Although Ruby only requires uppercase letters of a constant, we recommend that you use uppercase letters of a constant name for better readability.
Class personsFinger = 10; # define ConstantsPuts "Everyone has" + finger. to_s + "root
========================================================== ==========================================1. Can the methods in the Controller call each other?2. The @ variable defined in the control method is not an instance variable. It seems that it
The following pattern is commonly used to define method names in ruby.
Def method_name (arg1, arg2) # Some codeend
However, it is often seen in the code of books or other authors that=? !These three special weird symbols serve as the suffix of the
Running environment:
Ruby 1.8.6
Rails 1.2.5
Gem 1.0.1
The gmail server is used here. Because actionMailer in rails does not support TLS (SSL) connections, it is the only transmission method on the Gmail SMTP server. There is a plug-in provided for
For example, you write a class named SendMail and put it in a file named send_mail.rb,
If you attempt to reference this class in the same directory
Require "send_mail"
It's a waste of time, we need to add this paragraph
$:
This means that the
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