Broken free weekly Rails (e)
Advertisements
With no arguments, sets the default visibility for subsequently defined methods to . With arguments, sets the named methods to have visibility.
Many things in Ruby is just method!
2. System
Executes cmd in a subshell, returning true if the command was found and ran successfully, false otherwise. An error status is available in $?. The arguments are processed in the same way as for Kernel:: exec.
system("echo *")
system("echo", "*") # echo "*"
produces:
config.h main.rb *
3. `
Returns the standard output of running cmd in a subshell. The built-in syntax% x (...) uses this method. Sets $? To the process status.
`date` #=> "Wed Apr 9 08:56:30 CDT 2003\n" `ls testdir`.split[1] #=> "main.rb" `echo oops && exit 99` #=> "oops\n" $?.exitstatus #=> 99
4. Reload
Reloads the of this object from the database. The optional options argument is passed to when reloading so you may do eg record.reload (: lock => true) to the same record with an exclusive row lock.
When do you need to do reload? When you hold a object whose state may be changed by others.
5. Render: partial => 'shared / search', locals => (: objects => ...)
Why do we need locals? Partial is designed for reuse, so, you donot have to have the same name instance variable in your action, and locals make the reuse possible.
Related Posts of Broken free weekly Rails (e)
-
Rails2.0.2 change the default DB adpter
In Rails2.0.2 rails demo ... ... MissingSourceFile in SayController # hello no such file to load - sqlite3 RAILS_ROOT: / home / kenb / rails-projects / demo ... ... Checked config / database.yml, adpter default is set become the sqlite3. Check the ra ...
-
RSpec troubleshooting
1.uninitialized constant Dependencies Conditions: In windows under way to install the RSpec gem and rspec-rails. However, in ruby script / spec_server to do the test under the spec your_spec.rb-X will appear uninitialized constant Dependencies (NameE ...
-
Alternative to Java with Ruby to do unit testing interface rest!
Ruby is long overdue to replace java more flexible and make some necessary changes in a matter of, if not deep-rooted culture of the company's java, I think. . . . . . The following are my Writing for the Rest of the interface used to make the test su
-
Workspace run under different Eclipse
Now do live more and more often required to use eclipse in java and ruby & rails project conducted between the tangential shear from the past, because in the rails project used a coloring Aptana preferences, the results open the java project sour ...
-
Software development sunflower Baodian [reprint]
Master the ability to reuse code very familiar with the new API's fast. This is because, he once used a lot of the API, have a lot of reusable code. He knows what is available and what is deficient. He has been using Qt, also used by gtk +, also used
-
EJB
public transient int counter; / / transient property private String firstname; / / persistent property @ Transient String getLengthInMeter () (...) / / transient property String getName () (...) / / persistent property @ Basic int getLength () (...) / / p
-
Oracle instant clent for ruby / rails on cygwin
Environment: XP: oracle full client, ruby, rails, gem cygwin: ruby rails, gem (the version with the XP version) Needs: for cygwin is installed under the rails platform support oci Steps: <1> download oracle instant client (10.2.0.3 Instant Client Pa
-
can not be represented as java.sql.Timestamp
Development of procedures for the use of hibernate when, some time there is no need to fill in the fields, but after the hibernate query time reported "Java.sql.SQLException: Value'0000-00-00 'can not be represented as java.sql.Timestamp ...
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q












