2014年4月3日
摘要: 屏幕捕捉快捷键动作……………………….保存到…………-快捷键全屏捕捉……………………桌面(.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 阅读(156) 评论(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 阅读(130) 评论(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 阅读(216) 评论(0) 推荐(0) 编辑
摘要: https://github.com/Macrow/rails_kindeditorckeditor 阅读全文
posted @ 2014-04-03 16:16 qinyan20 阅读(229) 评论(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 阅读(164) 评论(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 阅读(300) 评论(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 阅读(378) 评论(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 阅读(1251) 评论(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 阅读(4294) 评论(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 阅读(824) 评论(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 阅读(274) 评论(0) 推荐(0) 编辑
摘要: class Greeter :greeterendFoo.new.hello # => "hello"Foo.new.goodbye # => NoMethodError: undefined method `goodbye' for # 阅读全文
posted @ 2014-04-03 16:07 qinyan20 阅读(147) 评论(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 阅读(105) 评论(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 阅读(133) 评论(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 阅读(277) 评论(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 阅读(137) 评论(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 阅读(144) 评论(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 阅读(243) 评论(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 阅读(336) 评论(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 阅读(170) 评论(0) 推荐(0) 编辑