摘要:
屏幕捕捉快捷键动作……………………….保存到…………-快捷键全屏捕捉……………………桌面(.PDF文件)……Command + Shift + 3 (win+shift+3)屏幕部分画面………………..桌面(.PDF文件)……Command + Shift + 4 (win+shift+4)窗口、图标………………….桌面(.PDF文件)……1. Command + Shift + 4 (win+shift+4)……………………- ……………………..-2. 空格全屏捕捉……………………剪贴板…………..Ctrl + Command + Shift + 3屏幕部分画面………………..剪贴板……… 阅读全文
posted @ 2014-04-03 16:23
qinyan20
阅读(162)
评论(0)
推荐(0)
摘要:
User.joins(:user_corps).where("user_corps.corp_id in (?) and user_corps.is_onjob = ?", [1,3,5],1).order('user_corps.id desc')Event.includes(:category).where( :category => { :position => 1 } ) 阅读全文
posted @ 2014-04-03 16:21
qinyan20
阅读(149)
评论(0)
推荐(0)
摘要:
ActiveRecord::Base.connection.execute("update corps set followers_count = 4 where id = 162")类似这种,如果ActiveRecord中已查出了数据,还需要reload一下更新count,或者手动更新 阅读全文
posted @ 2014-04-03 16:17
qinyan20
阅读(224)
评论(0)
推荐(0)
摘要:
https://github.com/Macrow/rails_kindeditorckeditor 阅读全文
posted @ 2014-04-03 16:16
qinyan20
阅读(240)
评论(0)
推荐(0)
摘要:
白名單逸出http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html預設允許的HTML標籤和屬性如下:ActionView::Base.sanitized_allowed_tags=> #ActionView::Base.sanitized_allowed_attributes=> #如果需要增加,可以在config/application.rb中新增,例如:config.action_view.sanitized_allowed_tags = %w[table tr td]config.act 阅读全文
posted @ 2014-04-03 16:15
qinyan20
阅读(176)
评论(0)
推荐(0)
摘要:
1. 删除远程分支social git branch -d -r origin/social 删除服务器分支:git push origin :social 2. 查看远程分支 git branch -a 3.在本地版本库中删除所有远程版本库中已不存在的分支 git remote prune 4.新 阅读全文
posted @ 2014-04-03 16:14
qinyan20
阅读(305)
评论(0)
推荐(0)
摘要:
有时你在写迁移任务的时候可能会不小心写错,如果你已经执行了这个迁移任务,那么, 你就不能单纯地把它修改一下再重新执行一次, Rails 会认为这个迁移任务已经执行过了, 所以执行rake db:migrate时不会做任何操作。你应该先把写错的那个迁移任务回滚(可以执行rake db:rollback),然后修改你的migration再执行rake db:migrate去 执行正确的版本。新增一個 Migration 檔案rails g migration migration_namemigration_name 常見的命名方式有Add欄位名To表格名或是Remove欄位名From表格名,不過這 阅读全文
posted @ 2014-04-03 16:12
qinyan20
阅读(415)
评论(0)
推荐(0)
摘要:
1、下载:http://www.elasticsearch.org/download/,本人下载的是:elasticsearch-0.90.7.tar.gz 包Java代码$tarzxvfelasticsearch-0.90.7.tar.gz$cdelasticsearch-0.90.7/ Once installation is complete, start ElasticSearch.Java代码$./bin/elasticsearch-f 阅读全文
posted @ 2014-04-03 16:11
qinyan20
阅读(1260)
评论(0)
推荐(0)
摘要:
相当于 Ubuntu/Linux 的 apt-get,用来安装一些零零碎碎的东西很方便,而且更新很快,安装的软件也都是最新版本。1. 安装Homebrew是使用 ruby 写的,采用 github 来存放信息库,很方便吧。Ruby 已经内置,最好装上 Xcode,因为可能需要一些编译包。然后在终端执行以下命令。$ ruby -e "$(curl -fsSLkhttps://gist.github.com/raw/323731/install_homebrew.rb)"brew 安装的软件存放在 /usr/local/Cellar 中,同时会在 /usr/local/bin, 阅读全文
posted @ 2014-04-03 16:10
qinyan20
阅读(4316)
评论(0)
推荐(0)
摘要:
先去官网下载http://www.mongodb.org/downloads建议下载64位的,32位的有一些限制,这个看书都会提到我下载的是mongodb-osx-x86_64-2.0.3.tgz 看《mongodb权威指南》说的偶数版本号是稳定版,奇数版本号是开发版。但看网站说推荐安装这个版本,看大版本也是稳定版,无所谓啦,反正也是学习,好多的基础知识建议多看《mongodb权威指南》因为下载的是二进制包安装就很简单tar zxvfmongodb-osx-x86_64-2.0.3.tgzsudo mvmongodb-osx-x86_64-2.0.3.tgz /usr/local/mongod 阅读全文
posted @ 2014-04-03 16:09
qinyan20
阅读(838)
评论(0)
推荐(0)
摘要:
gem installmysql2brew install mysql gem install mysql2http://stackoverflow.com/questions/12811489/installing-mysql2-gem-rails-on-macgem install pgMake sure you have Xcode installed first.Run:brew install postgresqlAdd to your GemFile:gem 'pg'Run:bundle installhttp://stackoverflow.com/questio 阅读全文
posted @ 2014-04-03 16:08
qinyan20
阅读(280)
评论(0)
推荐(0)
摘要:
class Greeter :greeterendFoo.new.hello # => "hello"Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for # 阅读全文
posted @ 2014-04-03 16:07
qinyan20
阅读(153)
评论(0)
推荐(0)
摘要:
countClient.count(:age)平均值Client.average(“orders_count”)最小值Client.minimum(“age”)最大值Client.maximum(“age”)总和Client.sum(“orders_count”) 阅读全文
posted @ 2014-04-03 16:06
qinyan20
阅读(123)
评论(0)
推荐(0)
摘要:
如果你仅仅想检查一条记录是否存在,可以使用exists?方法。这个方法会像find方法一样查询数据库,但是它返回的是true或者false。Client.exists?(1)exists?方法可以接受多个 id 作为参数,但是注意只要任何一条记录存在它都会返回 true 。Client.exists?(1,2,3) 或者 Client.exists?([1,2,3]}直接在一个 model 或者 relation 实例上调用不带参数的exists?方法也是可以的。Client.where(:first_name => ‘Ryan’).exists?上面的例子中,如果至少有一个first_ 阅读全文
posted @ 2014-04-03 16:05
qinyan20
阅读(180)
评论(0)
推荐(0)
摘要:
多条件查询:Client.where(“created_at >= :start_date AND created_at params[:start_date], :end_date => params[:end_date]})数列式条件表达式Client.where(:created_at => (params[:start_date].to_date)..(params[:end_date].to_date))子集条件表达式Client.where(:orders_count => [1,3,5])find_each andfind_in_batches:batch 阅读全文
posted @ 2014-04-03 16:04
qinyan20
阅读(286)
评论(0)
推荐(0)
摘要:
spec_helper.rbRSpec.configure do |config|# ...config.after(:all) doif Rails.env.test?FileUtils.rm_rf(Dir["#{Rails.root}/spec/support/uploads"])endendend# put logic in this file or initalizer/carrierwave.rbif defined?(CarrierWave)CarrierWave::Uploader::Base.descendants.each do |klass|next i 阅读全文
posted @ 2014-04-03 16:03
qinyan20
阅读(148)
评论(0)
推荐(0)
摘要:
登录验证:Authlogic:authlogic作为一款强大的登录验证插件,受到不少人的喜欢,使用非常简单,支持rails3,可以参考github上的api:http://github.com/binarylogic/authlogic权限管理:CanCan:CanCan是一个用于RubyonRails权限控制的解决方案,支持Rails3。http://github.com/ryanb/cancan搜索:meta_search:在Rails2中,相信很多人都在用binarylogic的searchlogic,此插件非常好用,但是并不支持Rails3,所以当我在开发Rails3项目的时候,只好忍 阅读全文
posted @ 2014-04-03 16:02
qinyan20
阅读(162)
评论(0)
推荐(0)
摘要:
Mac 下用 Nginx + Passenger 部署 Rails 的运行环境http://ruby-china.org/wiki/mac-nginx-passenger-railsubuntu下用 Nginx + thin 部署 Rails 的运行环境http://developer.51cto.... 阅读全文
posted @ 2014-04-03 16:01
qinyan20
阅读(263)
评论(0)
推荐(0)
摘要:
第一行result应该等于5; 第二行result应该包含5; 第三行result应该响应hello; 第四行lambda匿名函数应该抛出错误信息“Nothing find!”; 第五行result应该匹配正则表达式;第六行期望代码块能把bug状态从“open”改为“fixed”;第七行result应该为空;Should() 方法表示肯定,还有should_not()方法表示否定,该方法的工作机制是先执行should或者should_not后边的代码,返回一个 match对象,进而把此match对象作为参数传给should()或者should_not()方法,和拥有对象句柄的本地matc... 阅读全文
posted @ 2014-04-03 16:00
qinyan20
阅读(351)
评论(0)
推荐(0)
摘要:
为了进行测试,我们希望确保测试数据库具有与开发数据库相同的表结构。我们不必管理那些装载数据库模式的 DDL 脚本,而是使用 Rake 命令帮助创建测试环境。运行rake --tasks命令,就会显示几个用来构建或清空测试数据库的命令:清单 3. Rake --tasks 输出rake db:test:clone # Recreate the test database from the current # environment's database schemarake db:test:clone_str... 阅读全文
posted @ 2014-04-03 15:59
qinyan20
阅读(178)
评论(0)
推荐(0)
摘要:
BeforeclassPhoto<ActiveRecord::Base STATUSES =['queued','new','changed','removed','ready'] def change_status self.status ='changed' e... 阅读全文
posted @ 2014-04-03 15:58
qinyan20
阅读(181)
评论(0)
推荐(0)
摘要:
1.http://rubymonk.com/“小 和尚去化斋,老和尚有交待”,小和尚跟着老和尚学Ruby,现在有有6个Lesson,包括Ruby Collection, Ruby Object, OOP, String, Hash,Control Structure等,看完之后ruby基础就ok了。网站还是Alpha版本,还有很多功能正在添加中。2.http://www.therubygame.com/每周出一个题目,每个人都可以提交自己的答案,题目很简单。然后比较出谁的代码运行最快,代码最短。很有趣。3.http://rails-bestpractices.com/Rails最佳实践,Rub 阅读全文
posted @ 2014-04-03 15:57
qinyan20
阅读(329)
评论(0)
推荐(0)
摘要:
classPhoto'complete') scope :batch, unscoped.where(:status=>'batch') scope :queue, unscoped.where(:status=>'queue') scope :ongoing, -> { where(end_... 阅读全文
posted @ 2014-04-03 15:54
qinyan20
阅读(276)
评论(0)
推荐(0)
摘要:
1、新建工程时不使用test-unitrails new myapp --skip-test-unit2、添加gem修改Gemfilegroup :development, :test do gem 'rspec-rails' #会自动引用RSpec gem 'spork' #引入Spork gem "autotest-rails" #与ZenTest一起实现自动化测试 gem "ZenTest"end安装bundle install3、配置rspecrails generate rspec:install会生成以下文件: 阅读全文
posted @ 2014-04-03 15:53
qinyan20
阅读(368)
评论(0)
推荐(0)
摘要:
不 知广大Ubuntuer有没有收到过带个winmail.dat的邮件,我想在公司用Ubuntu办公的一定收到过不少这种麻烦邮件。而你完全不 知道这个附件如何打开,甚至更惨的是原本附件在邮件中的文件也不幸被这个winmail.dat吃掉了。你也许会询问这封邮件的发件人,这个时候对方多半 也是一头雾水,因为人家用Outlook用的好好的,从来没有听说过这个问题,说得直白一点,就是完全不知道你在说什么。 那么winmail.dat到底是个啥东西呢?是M$的工具在编码打包你的邮件进行发送时,如果按照默认指定的RTF格式,会把格式信息按照MS自己的一套标准存放在邮件体中(在此,强烈BS M$的这种做. 阅读全文
posted @ 2014-04-03 15:51
qinyan20
阅读(271)
评论(0)
推荐(0)
摘要:
grape_urlhttp://www.open-open.com/lib/view/open1356229655416.htmlhttps://github.com/ruby-china/ruby-china/blob/master/app/grape/api.rb#L7http://intridea.github.io/grape/docs/index.htmlgrape_swagger_urlhttp://dev.af83.com/2013/11/12/how-to-document-your-grape-api-using-swagger-ui.htmljquery链接http://a 阅读全文
posted @ 2014-04-03 15:45
qinyan20
阅读(283)
评论(0)
推荐(0)
摘要:
获得密钥:ssh-keygen -t rsa -C "aa@aa.com"链接githubaa@aa:~/dema$ ssh -T git@github.comHi username! You've successfully authenticated, but GitHub does not provide shell access.设置用户名和邮箱aa@aa:~/demo$ git config --global user.name "username"aa@aa:~/demo$ git config --global user.email 阅读全文
posted @ 2014-04-03 15:43
qinyan20
阅读(582)
评论(0)
推荐(0)
摘要:
js去掉前后空格$.trim(" a ")onclick事件: 点击这里document.write("This is a heading");document.getElementById("demo").innerHTML="My First JavaScript";获取 getElementById("demo") getElementTagName(); getElementByClass("demo")定义方法 时间和日期 d=new Date().getDay() 阅读全文
posted @ 2014-04-03 15:42
qinyan20
阅读(191)
评论(0)
推荐(0)
摘要:
js获取随机时间戳 (new Date()).getTime() 阅读全文
posted @ 2014-04-03 15:41
qinyan20
阅读(210)
评论(0)
推荐(0)
摘要:
$('.teach_list').click(function() { $('.mba_business_body ul.teach_li').toggle(); $('.teach_list').toggleClass('root'); }); $('.teach_list').bind({ click: function() { $('.mba_business_body ul.teach_li').toggle(); $('.teach_list').toggleClass(& 阅读全文
posted @ 2014-04-03 15:40
qinyan20
阅读(132)
评论(0)
推荐(0)
摘要:
查找 name为‘琴’开始的数据db.users.find({"name":/^琴.*/}).limit(10)mongodb由C++写就,其名字来自humongous这个单词的中间部分,从名字可见其野心所在就是海量数据的处理。关于它的一个最简洁描述为:scalable, high-performance, open source, schema-free, document-oriented database。MongoDB的主要目标是在键/值存储方式(提供了高性能和高度伸缩性)以及传统的RDBMS系统(丰富的功能)架起一座桥梁,集两者的优势于一身。安装及使用:首先在Ub 阅读全文
posted @ 2014-04-03 15:39
qinyan20
阅读(127)
评论(0)
推荐(0)
摘要:
慎用establish connection在一个Rails应用中连接多个数据库,我们常常这么做:Ruby代码classCookie<ActiveRecord::Baseestablish_connection:monitor_spider...end这样,在使用Cookie.find等操作的时候,... 阅读全文
posted @ 2014-04-03 15:32
qinyan20
阅读(565)
评论(0)
推荐(0)
摘要:
update_attributes=assign_attributes+saveattributes== alias ofassign_attributesupdate= alias ofupdate_attributesassign_attributes 更新对象,不保存 阅读全文
posted @ 2014-04-03 15:29
qinyan20
阅读(189)
评论(0)
推荐(0)
摘要:
grape_urlhttp://www.open-open.com/lib/view/open1356229655416.htmlhttps://github.com/ruby-china/ruby-china/blob/master/app/grape/api.rb#L7http://intridea.github.io/grape/docs/index.htmlgrape_swagger_urlhttp://dev.af83.com/2013/11/12/how-to-document-your-grape-api-using-swagger-ui.html 阅读全文
posted @ 2014-04-03 15:21
qinyan20
阅读(30)
评论(0)
推荐(0)
浙公网安备 33010602011771号