Like most object-oriented languages, ruby classes also allow you to define class variables and methods. A class variable allows a single variable to be shared among all instances of a class. In Ruby, two @@ numbers are used to indicate class
1 Dynamic Evaluate Code
Global method Eval compiles and executes a string containing a snippet of Ruby code, which is a very strong mechanism because it allows you to build the runtime
Code to execute. Look at the following example:
Ruby Code
Tutorial we will talk about using Photoshop mouse to paint a lifelike ruby ring process, the completion of this work, although the need for a certain painting skills, but not too difficult, as long as we follow the study can be mastered.
Let's take
%q
A string that replaces double quotes. When you need to put a lot of quotes in a string, you can use the following method directly without adding a backslash (\) to the quotation mark.
Copy Code code as follows:
>>%q (Joe said:
Requirements for: input points from the keyboard, in order to judge, 0-59 for the failure, print "You did not pass, please try next time!", 60-79 for passing, print "Your grades pass, please work harder!" ", 80-100 for good results, print" Your
%{string} is used to create a string enclosed in double quotes%q{string} is used to create a string enclosed in double quotes
Copy Code code as follows:
Str=A string
End_of_string
%q! Some String of "Characters"! "Some
1, Ruby in the method name and variable name rules ( beginning with lowercase letters, the separation between words using "_",), but you can take the method name behind! (blockbuster method) or? (A Boolean type returns a value).
2, the method of
A previous article about the use of Git hook deployment application, hook method has a flaw is to go to the server every time to modify the hook corresponding configuration file, this profile is separated from the current warehouse, debugging will
The method in Ruby is a code block with a name and is a parameterized code associated with one or more objects. The invocation must give the method name, the receiver (the object), the parameter value, and the value of the last expression as the
The SMTP (Simple Mail Transfer Protocol) is simply a mail Transfer protocol, a set of rules for sending messages from the source address to the destination to control how the letters are transferred.
Ruby provides net::smtp to send mail, and
Ruby provides two levels of access to the network, at the bottom you can access the operating system, it allows you to implement the client and server for the connection-oriented and connectionless protocol basic socket support.
Ruby Unified
Using Git to manage code engineering is a lot more convenient, but when you're done feature branch or finish hotfix, always forget to delete these useless branches, one by one delete really troublesome, repetitive manual labor is not in line with
In the previous essay, we tested Login_controller, and we used a lot of rails built in assertions and get,put to test it. Take a look at some of the rails ' conventions on functional testing this time.
1.HTTP requested methods (HTTP request method)
Last we achieved the login page, now we distinguish between the administrator and ordinary users, according to the user's different identities, into different pages
Filter is provided in rails to intercept requests to access an action, and you can
This article will focus on how to build a ROR development environment under different operating systems and, at the end, detail how to install and configure the MySQL database under Windows operating systems.
Construction of development environment
Many-to-many associations in rails are implemented by declaring Has_and_belongs_to_many in the class corresponding to the associated table.
In a database, Many-to-many associations are implemented using an intermediate table, which includes the
A One-to-many association allows us to represent a set of objects, for example, an order can contain any number of line item, and in the database, all line item records are associated with a foreign key to a particular order.
In an active record,
Rails supports three of relationships between tables, one-to-one, One-to-many, Many-to-many, and you need to include a declaration in model to identify these associations: Has_one,has_many,belongs_to,has_and_belongs_to_many.
A one-to-one
Before learning the processing of concurrent processing in rails, let's take a quick look at the concept of concurrent processing.
In applications that have multiple processes that access the same database at the same time, this can happen because
The Active record provides two methods to get the number of records that match the criteria: count () and Count_by_sql (). For example:
C1 = order.count
C2 = Order.count (["name =?", "Dave Thomas"])
C3 = Lineitem.count_by_sql ("SELECT COUNT (*)" +
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.