The module in ruby is a bit similar to the namespace in. net. It can be used to distinguish the module with the same name but belongs to different developers (or organizations ).Code.
The following code defines an me module, in which SQRT is the
1. Open and read files
File = file. Open ("cnblogslink.txt") file. Each {| Line | print "# {file. lineno}.", line} file. Close
Output:
1.Community 2. News
3. Community
4. News
5. Recruitment
6. Bo Wen
7. Group8. Flash9. Network
Reference books: Agile web development with rails 4th Edition
Create a new website and create some default directories and files:
$ Rails new
Start the server and run the following command in the project directory:
$ Rails Server
Default
1. Create a folder Dir. New % 1Dir: mkdir # When the full directory name is not specified, the default value is the working directory.Dir: chdir () change the working directory of the current scriptFileutils. mkdir 'test'File = file. New ("cmd.txt ")
Ror deployment methods are divided into front-end and back-end architectures:
I. Front-end
The frontend is used to process static resources, distribute dynamic requests to the backend, and sometimes provide some additional functions, such as
1. Equal?
We often need to compare two objects. Ruby provides a variety of methods for comparing objects. We can use equal? The method is used to compare whether two objects are the same. This method is used to compare whether two values point to
1. First read the object_id of the string.
Str1 = "anleb" str2 = "anleb" puts str1.object _ idputs str2.object _ id
Output:2295250022952490
Different IDs indicate that objects have the same values, but they are different. What is different,
Ruby on Rails is a Web application that enables you to develop, deploy, and maintain
ProgramA simple framework.
Of course, all web frameworks share the same goal. What makes rails so different? We can answer this question in several ways.
First,
Some important differences between Ruby and C # are as follows:
1. Ruby is a dynamic language, and C # Is a static language-that is, after an object is new, Ruby can dynamically add some attributes or methods to the object instance (as does
Complained todayThe blog has not been updated for many days, which affects reading mood. I just need to start it. ^_^
# Part One
Afile = file. New ("C: \ 1.txt"," W ")
Afile. Puts "The 1"
Afile. Puts "The 2"
Afile. Close
# Part Two
What is jruby?
Jruby is a Ruby interpreter implemented in pure Java. Through jruby, you can directly run Ruby on JVMProgramTo call the Java class library. Many Ruby ides written in Java use jruby to explain the syntax.
Jruby, an open-source Ruby
Dynamic scripts in recent yearsProgramming LanguageIn China, Python and Ruby are becoming more and more popular, and they are often compared. I think they have their own characteristics:
51cto editing recommendations: Ruby tutorials and tips
1.
I want to be a professional technical writer, but I am too emotional to write rigorous technology.Article, Always like to show too many emotional colors in your own articles. This series of articles shows my recent feelings from the name, and it is
Linux installation: I used the source code compilation method for installation. The operating system is Red Hat Linux release 7.3 (Valhalla)
Download from the ruby Main SiteSource code, "Get Ruby now!" on the right of the Home Page !! ", Which
From the technical point of view, Ruby itself is really nice.ProgramThe work of Members becomes easy and interesting!The followingCodeDemonstrate how to find a prime number less than 100:
Copy code The Code is as follows: using system;
Namespace
You may have noticed that in our previous code, the database definition uses an integer field id as the primary key, which is a convention of Active Record.
Maybe you have to ask, why don't we use order numbers or a meaningful column as the
The Ruby pp () function can be used to output arrays in a very beautiful way. However, the disadvantage is that the two-dimensional array is displayed on one row. We want it to be output in the form of a subarray per row, as shown in
Is it more
Git repository outputGit archive -- format = tar -- prefix = actasfavor/HEAD | (cd/home/holin/work/& tar xf -)Output to the/home/holin/work/actasfavor/directory
Posted by holin At May 16,200 8Load controller and model in plugins
# Include hook code
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