rails调试
最初用rails调试是用puts输出,后来开始测试驱动之后就没怎么调试了,哪测试不过直接找原因,实在需要看运行时就在测试里用pp,然后还是看guard输出。后来在一个公司工作,他们调试都是logger.info然后查日志,因为不是在本地调试而是直接在服务器上调试。今天才知道原来pry调试这么方便。。...
程序员文章站2022-07-15rails assets precompile
在自己的项目中用了bootstrap-sass,但是在heroku上跑会出现一个问题,没有找到assets。后来的解决办法是每次上传到heroku上之前都执行以下 rake assets:precompile,把assets编译以下,然后上传静态文件。一段时间后又遇到一个问题,每当我想用glyphi...
程序员文章站2022-07-15rails find find_by 和 where 区别
User.find(1) User.find_by(name: "ff")和User.where(id: 1) User.where(name: "ff")区别在于,where找不到会返回空数组,find和find_by会抛异常。
程序员文章站2022-07-15ubuntu14.10 rails env
sudo apt-get install virtualbox-guest-dkmssudo apt-get install curl\curl -sSL https://get.rvm.io | bashwget https://dl.google.com/linux/direct/google-...
程序员文章站2022-07-15Rails flash
flash是个hash用于在两个actions间传递临时数据,flash中存放的所有数据会在紧接着的下一个action调用后清除。一般用于传递提示和错误消息。class PostsController < ActionController::Base def create # save...
程序员文章站2022-07-15Rails事物Transaction
以前用.net和Oracle常常用到Transation,目的是在进行复杂的数据库逻辑时保证中间某一环节出错后,数据回复原状,不会产生错误数据。在Rails中也有Transation:ActiveRecord::Base.transaction do david.withdrawal(100) ...
程序员文章站2022-07-15在heroku上部署Rails和遇到的问题
1.Heroku 使用 PostgreSQL(发音 post-gres-cue-ell,经常简称 Postgres),所以我们要把 pg 加入生产组,Rails 才能和 PostgreSQL 通信:group :production do gem 'pg', '0.15.1'end 2.login...
程序员文章站2022-07-15Rails常用命令
test环境数据库签移: $ rake db:migrate RAILS_ENV=test $ rake test:prepare启动server的环境变量: $ rails server --environment production改变控制台环境: $ rails console test
程序员文章站2022-07-15rails 中调用数据库函数
# 根据底线维护周期计算当前维护周期的底线维护周期 def calculate_current_maintenance_date deadline = ActiveRecord::Base.connection.execute("select calculate_current_main...
程序员文章站2022-07-15Rails form_tag的remote参数说明
在remote为true时,rails会以ajax的方式提交表单,实现无刷新。可是当form中含有fileupload的时候,remote就会失去作用,rails还是会以传统form的方式刷新页面。据说这个gem可以有效解决这个问题。 Remotipart
程序员文章站2022-07-15Rails 3下的 in place editor edit in place
第一个版本http://code.google.com/p/jquery-in-place-editor/demohttp://jquery-in-place-editor.googlecode.com/svn/trunk/demo/index.htmlgit地址https://github.com...
程序员文章站2022-07-15RVM切换Ruby和Rails版本
目的是运行多个ruby和rails版本apt-get install git-core ...3个,参考我博客其他文章apt-get curl安装RVM详见:https://rvm.beginrescueend.com/rvm/install/照着做。如果是Multi-user,rvm会被自动安装到...
程序员文章站2022-07-15Rails ubuntu IDE使用总结vim,RubyMine,Redcar,NetBeans
开发环境ubuntuvim只是一个编辑器,没有IDE窗口。sudo apt-get install vimvim的使用:vim 文件名;在vim编辑窗口中,按"Insert"键进入插入状态,鼠标在光标处点击右键粘贴下面这段代码。 按"Esc"键,退出插入状态,输入命令":q"退出,":wq",保存并...
程序员文章站2022-07-15Mac下用Whenever和Cron Job集成Rails
https://github.com/javan/wheneverhttp://*.com/questions/14612818/whenever-gem-i-set-output-but-the-logfile-doesnt-show-up-where-id-expect-...
程序员文章站2022-07-15Mac搭建Ruby on Rails Postgresql解决方案
Maccbook OSX10.8.2注意1 :HomeBrew 安装 Postgresql注意:Postgresql版本就用9.2的,因为Mac自带的用的是9.2的,否则会冲突。$ brew search postgresql注意2: $ rails new duok -d postgresql$ ...
程序员文章站2022-07-15Mac下用Whenever和Cron Job集成Rails
https://github.com/javan/wheneverhttp://*.com/questions/14612818/whenever-gem-i-set-output-but-the-logfile-doesnt-show-up-where-id-expect-...
程序员文章站2022-07-15Mac搭建Ruby on Rails Postgresql解决方案
Maccbook OSX10.8.2注意1 :HomeBrew 安装 Postgresql注意:Postgresql版本就用9.2的,因为Mac自带的用的是9.2的,否则会冲突。$ brew search postgresql注意2: $ rails new duok -d postgresql$ ...
程序员文章站2022-07-15rails bug 如果表字段有名字为type的bug RailsRubyActiveRecordCC++
今天在做开发的时候遇到一个莫名奇妙的问题,后来才发现是表中有字段名字叫type引起的,还是在http://dev.rubyonrails.org/ticket/7998 上发现原来是rails的一个bug,发出来,免得大家遇到相同的问题。Ticket #7998 (new defect)Open...
程序员文章站2022-07-15rails i18n 中文语言包
https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/zh-CN.yml 下载 zh-CN.yml 到 config/locales 目录下。修改 config/application.rbconfig.i18n.defau
程序员文章站2022-07-15rails i18n 中文语言包
https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/zh-CN.yml 下载 zh-CN.yml 到 config/locales 目录下。修改 config/application.rbconfig.i18n.defau
程序员文章站2022-07-15