tailieunhanh - Rails for Java Developers phần 2

Sau này Matz cũng bất ngờ khi phát hiện ra Pearl là viên đá quý tượng trưng cho những người sinh tháng 6, còn Ruby thì tượng trưng cho những người sinh tháng 7. Anh cho rằng cái tên Ruby như thế là phù hợp vì Ruby kế thừa và phát triển nhiều đặc tính từ Perl | Running the Samples 31 It is possible to type longer blocks such as this three-line block irb main 002 0 if true irb main 003 1 puts tautology irb main 004 1 end tautology nil If you make as many typing mistakes as we do you can also paste multiple lines of code into irb. When code starts to be long enough that it is unwieldy to enter into irb you will want to switch to full Ruby programs. Running Ruby Samples All the Ruby samples for the book are from the rails_xt samples directory unless otherwise noted in the text. So if you see the following command ruby you can execute the same command within the rails_xt samples directory after you unzip the sample code. Running Rails Samples The samples include a Rails application in the rails_xt directory. All Rails commands should be run from this directory unless otherwise noted. When you see a command that begins with script such as script console or script server run that command from the rails_xt directory. The script console command is particularly important. It gives you an interactive Ruby shell with Rails and your application s environment already loaded. Try running script console from the rails_xt directory in the sample code. script console Loading development environment. puts Hello Hello This is just like irb except you can also now call Rails API methods. For example you could ask what database Rails is using ActiveRecord rails4java_development The default prompt in script console is . When you see this prompt in the book you should be able to run the same code using script console in the rails_xt directory. Rails Environments 32 Running the Unit Tests We wrote much of the code in this book as exploration tests. Exploration exploration tests tests are unit tests written for the purpose of learning teaching and exploring. sample code should be tested for the same reason people unit test anything else It is easy for us and you to quickly verify that the code works