Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394

5星(超过95%的资源)
所需积分/C币:16 2016-03-07 09:50:49 3.36MB PDF
32
收藏 收藏
举报

A step by step guide to learn Ruby on Rails 5.0. It includes a basic tutorial for Ruby 2.3 and is written for programmers who know at least one other programming language and are familiar with HTML. It covers Active Record, Scaffolding, REST, Routing, Bundler, Test Driven Development, Cookies, Sessions, Action Mailer, I18n, Asset Pipeline, JavaScript, Caching, Templates and of course the new 5.0 features Action Cable and Active Job. Table of Contents Preface Ruby Basics First Steps with Rails ActiveRecord Scaffolding and REST Routes Bundler and Gems Forms Tests Cookies and Sessions Active Job Action Mailer Internationalization Asset Pipeline JavaScript Caching Action Cable Templates Ruby on Rails Install How-to Further Rails Documentation
PREFACE Don't let people fool you into believing that ruby on rails is easy to learn. It is not! It's probably the best and most effective framework to develop web applications but it is hard to understand in the beginning. The worst mistake of all is to not learn ruby before diving into Ruby on Rails. To avoid it this book starts with the basics of Ruby. You will not become a ruby guru after reading it but you'll understand the basic ideas and that important I wrote this book for developers who learn best by following clean examples. i dont like he idea of coding one big single application throughout a book but prefer smaller stand- alone code examples. Therefore you can skip a couple of pages or even complete chapters without losing context Shameless plug: Please contact me by e-mail to stefan wintermeyer@amoomade if you need Ruby on Rails consulting or training Have fun with Ruby on rails Stefan wintermeyer Ps:IpostupdatesaboutthisbookandRailsingeneralathttps://twitter.com/wintermeyer Stefan Wintermeyer RUBY BASICS Introduction This book requires basic knowledge of HTML, plus the reader -you, in other words should also have a basic understanding of programming. The beginning of this chapter is going to be a bit boring. Bcar with me. It's worth it It is easy to program in Ruby, but ruby is not a simple language.” n Yukihiro matsumoto This chapter is a tightrope walk between oversimplification and a degree of detail that is unnecessary for a Rails newbie. After all, the objective is not becoming a Ruby guru, but understanding Ruby on Rails. I am going to elaborate on the most important points. The rest is then up to you. If you would like to know more about Ruby, then i recommend the book"The Ruby Programming Language"by David Flanagan and Yukihiro Matsumoto The command ruby -v will print the current running Ruby version sp ruby -V ruby2.3.p0(2015-12-25 revision53290)[X8664- darwin15] $ Hello World Ruby is a scripting language so it is not compiled and then executed but read by an interpreter and then processed line by line A simple ruby program hello-world. rb consist of the following line Listing 1. hello-world rb puts 'Hello World Use your favorite editor to open a new file with the filename hello-wor ld. rb and insert the above line into it. You can then execute this Ruby program in the command line as follows s ruby hello-world rb Hello wor ld i $ a program line in a Ruby program does not have to end with a semicolon. The ruby interpreter is even so intelligent that it recognizes if a program line was split over two on more lines for the sake of readability. I will spare you the corresponding examples and am only mentioning this so you don't say or think later, is it okay like this? Indenting code is also not necessary. But it does make it much easier to read for human beings puts and print If you go looking for examples on Ruby on the Internet, you will find two typical ways of printing text on the screen puts prints a string, followed by a newline print prints a string(without new line) Example program(an extension of the program hello-world. rb) Listing 2. hello-world rb puts 'Hello world puts puts Zzz print Hello world! print puts ZZz On the screen, you will see this s ruby hello-world rb Hello world ZZZ Hello world! zzz Comments A comment in a Ruby program starts with a #-sign and ends with a newline. As an example, i can add a comment to the hello-world. rb above Listing 3. hello-world rb Program for displaying " Hello world! by stefan wintermeyer puts Hello world! A comment can also follow a program line Listing 4. hello-world rb Program for displaying "Hello World! by Stefan Wintermeyer puts Hello world! output A #-sign within strings in inverted commas is not treated as the start of a comment Example program Listing 5. hello-world rb Example program by stefan Wintermeyer puts Hello World! puts'并并并并H计并并H计并 puts puts'1并2#34并5#6#1# Comment on this Help via ri When programming, you do not always have a Ruby handbook available. Fortunately, the Ruby developers thought of this and provided a built-in help feature in form of the program ri (of course only if you have installed the documentation which is the default This is a typical chicken and egg situation. How can I explain the ruby help feature, if we are only just getting started with Ruby? So I am going to jump ahead a little and show you now you can search for information on the class String s ri string If we are looking for information on a specific method (chicken-egg! ), then we can also useri. Let's take gsub as an example. This is a method for replacing parts of a String (that is useful now and again) s ri String size = string size (from ruby site str size integer Returns the character length of str The program ri always prints the output in the pager program defined by the shell (for example less). You can also use the command option-t to output everything directly to STDOUT irb stands for Interactive Ruby and is a kind of sandbox where you can play around with Ruby at your leisure. irb is launched by entering irb on the shell and ends if you enter exit An example is worth a thousand words s irb > puts Hello World! I Hello world! nil exit $ I use IRB. conf[: PROMPT_MODE]=: SIMPLE in my .irbrc config file to generate shorter irb output. You can do the same by using irb --simple-prompt

...展开详情
试读 127P Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394
立即下载
限时抽奖 低至0.43元/次
身份认证后 购VIP低至7折
一个资源只可评论一次,评论内容不能少于5个字
paul712 还可以,谢谢分享
2018-02-13
回复
aunmro 感觉还行,只是感觉用着不是特别顺手.
2016-04-24
回复
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
  • 至尊王者

关注 私信
上传资源赚钱or赚积分
最新推荐
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394 16积分/C币 立即下载
1/127
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第1页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第2页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第3页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第4页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第5页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第6页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第7页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第8页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第9页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第10页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第11页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第12页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第13页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第14页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第15页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第16页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第17页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第18页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第19页
Ruby.on.Rails.5.0.for.Autodidacts.Learn.Ruby.2.3.and.Rails.5.0.152394第20页

试读结束, 可继续阅读

16积分/C币 立即下载