`
biyeah
  • 浏览: 200488 次
  • 来自: ...
社区版块
存档分类
最新评论
文章列表
Pry可看成是IRB的加强版。支持语法高亮等特点。 1、在Gemfile中添加: 引用group :development do gem 'pry' end 运行bundle install。 2、在config/environments/development.r文件最后面添加: 引用silence_warnings do   require "pry"   IRB = Pry end 保存即可。 运行rails console进入pry终端。 pry项目地址:https://github.com/pry/pry
https://github.com/camping/camping/blob/master/book/02_getting_started 直接看文档就知道了。 源代码不大4k左右值得研究。 Camping is a web framework which consistently stays at less than 4kB of code.You can probably view the complete source code on a single page. = Getting Started Start a new text file called nuts.rb. Here' ...

Markaby (Markup as Ruby)

    博客分类:
  • Ruby
http://markaby.rubyforge.org/ Markaby is a very short bit of code for writing HTML pages in pure Ruby. It is an alternative to ERb which weaves the two languages together. Also a replacement for templating languages which use primitive languages that blend with HTML. Using Markaby as a Rails plugin ...

Ruby的一些疑问

    博客分类:
  • Ruby
 
1、网点看到一断程序, def m1(a) puts 'invoke m1' puts a end def self.m1(a) puts 'invoke self.m1' a = 20 super end m1 10 运行结果如下: invoke self.m1 invoke m1 20 为何先运行self.m1,这里为何可以使用super?还弄不明白,先记下来。 2、下面的代码在rails源代码中看到的,不明白&:to_s的写法。 (1..10).map(&:to_s) 3、 def who   person = "Mat ...
小巧压缩包不到10M,可以通过安装插件扩展功能。还支持VIM模式,通过安装https://github.com/Kronuz/SublimeCodeIntel 插件后,能比较好的支持代码自动完成功能。 一些技巧:会不断更新 1、常用快捷键 F7或Ctrl + b 运行当前文件,ruby文件 ...

RSpec测试框架

    博客分类:
  • Ruby
#参考http://www.slideshare.net/ihower/rspec-7394497 #入门,框架 require 'rspec' class Order #自定义类 end describe Order do #一个类别 #可以Nested加入想要测试的方法是哪个 describe "#amount" do #通常用#开头表示实例方法,.开头表示类方法 context "when user is vip" do #可以再nested加入不同情境 before(:each) do #每段it ...

[转]Ruby - DUP vs CLONE

    博客分类:
  • Ruby
http://railsblogger.blogspot.com/2009/03/ruby-dup-vs-clone.html Ruby - DUP vs CLONE Both DUP & CLONE can be used to create shallow copy of an object. Both copies the instance variables of obj. But we need to be selective in their usage. Few difference between these are 1) CLONE copies both FRO ...
http://www.cnblogs.com/rubylouvre/archive/2011/08/28/2112321.html 前些天写html生成器的时候用到了erb,在生成html的时候是这么一句: html=tpl.result(binding) binding这个变量(Kernel的一个方法 T_T)有点古怪,就搜了下。它表示了ruby的当前作用域,没 ...

[转]Ruby中的binding

    博客分类:
  • Ruby
http://kkito.cn/index.php/blog/getArticle/82/ruby_binding 之前在看erb如何parse的时候发现使用了binding这个东东,没有怎么在意,后来发现很多地方都用到了这个binding。     仔细查了一下手册 Objects of class Binding encapsulate the execution context at some particular place in the code and retain this context for future use. The variables, methods, value ...
http://weblog.jamisbuck.org/2007/2/5/nesting-resources The RESTful routes feature in Rails makes it really, really simple to nest resources within each other. Just give a block to the “map.resources” call, and define further resources on the value yielded to that block: map.resources :accounts do | ...
From:http://weblog.jamisbuck.org/2007/2/23/method-visibility-in-ruby A common point of confusion to even experienced Ruby programmers is the visibility of public, protected, and private methods in Ruby classes. This largely stems from the fact that the behavior of those keywords in Ruby is different ...
不错的文章,出处:http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model When first getting started with Rails, it is tempting to shove lots of logic in the view. I’ll admit that I was guilty of writing more than one template like the following during my Rails novitiate: <!- ...
出处:http://syue.com/Software/Language/Ruby/740.html (十一、并发处理) 在学习Rails中的并发处理的处理前,我们先简单了解下并发处理的概念。   在有多个处理同时访问同一个数据库的应用程序中,可能会出现这样的情况,因为一个处理更新了数据库中的行,而使得另一个处理中持有的数据变得陈旧了。例如,A和B先后从数据库中提取了相同的数据,并都做了修改,这时B先将自己的修改更新会数据库,稍后,A将自己的修改更新回数据库,这时将会覆盖B所作的修改,当B再次提取数据库后,看到的是A修改的结果,而不是自己的。   一个解决办法就是将更新的表或者行进行锁定,防止其 ...
出处:http://syue.com/Software/Language/Ruby/713.html (一、ActiveRecord基础) ActiveRecord是Rails提供的一个对象关系映射(ORM)层,从这篇开始,我们来了解Active Record的一些基础内容,连接数据库,映射表,访问数据等。   Active Record使用基本的 ...
http://developer.51cto.com/art/200907/132919.htm    从模块引入方法、变量,使得编程变得简单,扩展性愈强,比以往的类的继承更灵活。这样的引入,仿佛将一个方法块,复制了一份放到了你所引用的类或者模块里面。你完全可以将多个互不相干的类中相同的方法拿出来写到一个模块中,这样可以使得代码精简,符合Ruby的设计初衷,而且,使得你的程序更有条理。 Ruby on Rails常见用法 通常引用模块有以下3种情况: 1.在类定义中引入模块,使模块中的方法成为类的实例方法 这种情况是最常见的 直接 include 即可 2.在类定义中引入模块,使模块 ...
Global site tag (gtag.js) - Google Analytics