ruby on rails
RunUpwind
这个作者很懒,什么都没留下…
展开
-
rails3 mysql2安装,incompatible character encodings: UTF-8 and ASCII-8BIT 解决!
问题环境:os: windows XP F:\>ruby -vruby 1.9.2p180 (2011-02-18) [i386-mingw32] F:\>rails -vRails 3.0.5 问题描述:1、安装不了mysql2 rails3 默认使用mysql adapter是mysql2. ...2011-04-13 15:42:47 · 270 阅读 · 0 评论 -
rails 如何清除clear session
参照:http://stackoverflow.com/questions/684457/how-do-you-clear-a-single-entry-from-a-ruby-on-rails-sessionhttp://stackoverflow.com/questions/2405635/how-to-empty-destroy-a-session-in-rails 清除sess...2011-06-22 13:50:21 · 349 阅读 · 0 评论 -
Ruby Net::HTTP cheat sheet
转自:http://augustl.com/blog/2010/ruby_net_http_cheat_sheet I always have to look up how to use Net::HTTP, and I never find what I’m looking for. Behold, a cheat sheet!A basic requestrequire "...原创 2011-06-22 19:03:16 · 163 阅读 · 0 评论 -
ruby on rails 读写yml文件(中文utf-8问题)
有一些配置,想通过WEB界面管理。但没有必要存入数据库,用yml文件方便些。 读文件比较简单: def self.get_config YAML::load(File.read(Rails.root.to_s + '/config/points_base_rules.yml')) end 读取对象之后,就可以显示在form上了,编辑之后,put 到server,...2011-06-29 11:41:23 · 406 阅读 · 0 评论 -
把表结构写进model(annotate_models,annotate)
在做ROR开发时,经常要去查schema.rb, 确实有些不便。 《Web开发敏捷之道-应用Rails进行敏捷Web开发-第三版》中提到一个插件可将数据库信息添加到model顶端:annotate_models。 因为书中所讲内容已是过去时了,已经找不到那个plugn了。 google得知:现在有这样的GEM了:https://github.com/sagework/a...2011-06-29 14:02:50 · 210 阅读 · 0 评论 -
rails created_at时区不对
参见:http://stackoverflow.com/questions/2512450/time-now-created-at-are-different-ruby-on-rails 将config/application.rb 中的config.time_zone = 前的注释去掉。改为:config.time_zone = 'Beijing' 即可。 ...2011-06-30 16:21:05 · 244 阅读 · 0 评论 -
to_json 中增加自定义的属性字段
参考:http://stackoverflow.com/questions/5111165/accessing-virtual-attribute-from-json 原本我这样写:@user.to_json(:only => [:id, :name, :pay_points]) 后来我想增加一个属性,它不是一个数据库字段,是在@user中定义的一个方法:def poin...原创 2011-07-06 17:59:16 · 304 阅读 · 0 评论 -
基于windows+ruby1.91安装rmagick
如题,试用N种方法,终于找了一个可用的方法:http://www.waydotnet.com/blog/2010/02/rmagick-on-ruby-1-9-1=-i386-mingw32-work-d/ 其中的环境变量设置那一步很重要,我第一次漏掉了,导致没有成功。 ...原创 2011-07-11 18:35:41 · 137 阅读 · 0 评论 -
rails 利用easy_captcha生成图片验证码
gem install easy_captcha 文档在这里: http://rubydoc.info/gems/easy_captcha/0.4.2/frames原创 2011-07-11 18:37:36 · 249 阅读 · 0 评论 -
linux安装rmagick经验总结
我的环境:ruby -v其中一台(32位):ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux] 另一台(64位):ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] rails -vRails 3.0.5 安装rmagick,首先要安装Im...2011-07-18 18:09:27 · 408 阅读 · 0 评论 -
Encoding::UndefinedConversionError: "\xE5" from ASCII-8BIT to UTF-8
在做编码转换时,遇了这个问题。原代码如下:str.encode('UTF-8') if str.encoding != 'UTF-8'所以就遇到了错误:Encoding::UndefinedConversionError: "\xE5" from ASCII-8BIT to UTF-8 后来看了https://github.com/lassebunk/webcam_app/i...原创 2011-07-21 11:59:41 · 2576 阅读 · 1 评论 -
ruby string replace用gsub
"Hello World".gsub("Hello", "Bye")原创 2011-07-21 17:16:21 · 861 阅读 · 0 评论 -
rails中如何添加自定义的请求格式
rails默认request的格式是 text/html. 同时还支持 xml 和 json. 如果要添加一个格式如.api, 访问路径:http://..../login.api, 该如何做? 参照:http://stackoverflow.com/questions/2456219/add-a-custom-format-in-rails-that-will-work...原创 2011-06-22 11:28:18 · 196 阅读 · 0 评论 -
rails接口验证:HTTP Basic Access Authentication
server端: 参照:http://railscasts.com/episodes/82-http-basic-authentication products_controller.rbbefore_filter :authenticateprotecteddef authenticate authenticate_or_request_with_h...原创 2011-06-22 10:05:50 · 240 阅读 · 0 评论 -
undefined class/module Function
my develop environment: windows xpF:\>ruby -vruby 1.9.2p180 (2011-02-18) [i386-mingw32]F:\>rails -vRails 3.0.5 在session中存了一个对象,并将session存到数据库中时,报错:undefined class/module Functi...原创 2011-06-10 16:24:07 · 158 阅读 · 0 评论 -
select_tag 的字符串参数要加html_safe
F:\>ruby -vruby 1.9.2p180 (2011-02-18) [i386-mingw32] F:\>rails -vRails 3.0.5 form_for 下的 select 是这么写的:<%= f.select :parent_id, options_tree_for_select(@departments) %>...原创 2011-05-06 11:31:48 · 142 阅读 · 0 评论 -
linux安装mysql适配器(系统自带的mysql)[rpm yum]
按照robbin的http://www.iteye.com/topic/43228中所述的“安装 ruby 的数据库适配器”方法安装时,找不到mysql安装路径。> whereis mysqlmysql: /usr/bin/mysql /usr/lib/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz ruby ext...2011-05-06 13:14:40 · 130 阅读 · 0 评论 -
OpenSSL support for Ruby
在按照http://binku.iteye.com/blog/483687 安装passenger时,提示需要 安装OpenSSL support for Ruby。 找到一个方案,经测试可以解决:http://serverfault.com/questions/114725/openssl-support-for-ruby-cipher-is-not-a-module-typeerr...2011-05-06 13:44:56 · 96 阅读 · 0 评论 -
Could not find tzinfo-0.3.26 in any of the sources
之前在开发机器上安装的rails 3.0.5 , 今天在生产机上布署,报错:Could not find tzinfo-0.3.26 in any of the sources 经查发现,今天安装的rails 3.0.5中其中有些gem的版本与我在开发机器上安装的不同。通过gem list 可以看到生产机安装的gem版本列表 再打开gemfile.lock, 将其中的gem...2011-05-06 15:24:32 · 328 阅读 · 0 评论 -
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter`
环境: linux ruby1.9.2 rails 3.0.5 mysql2 0.3.2遇到问题:Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` 解决方法:gem uninstall mysql2 thengem install mysql2 -v 0.2.7...2011-05-06 16:12:39 · 234 阅读 · 0 评论 -
rails3无法使用fckeditor改用ckeditor
my environment:F:\>ruby -vruby 1.9.2p180 (2011-02-18) [i386-mingw32]F:\>rails -vRails 3.0.5 需要用到图文编辑框时,自然想到了fckeditor,查找网上的文章,大同小异,如:http://www.blogjava.net/rocky/archive/2006/11/0...原创 2011-05-12 18:03:38 · 99 阅读 · 0 评论 -
rails3下安装ckeditor
my environment: windows xpF:\>ruby -vruby 1.9.2p180 (2011-02-18) [i386-mingw32]F:\>rails -vRails 3.0.5 在按照http://rubydoc.info/gems/ckeditor/3.5.3/frames 安装ckeditor时遇到了问题,又折腾了很久...2011-05-13 11:21:40 · 113 阅读 · 0 评论 -
安装paperclip ImageMagick(Paperclip::NotIdentifiedByImageMagickError:)
my develop environment: windows xpF:\>ruby -vruby 1.9.2p180 (2011-02-18) [i386-mingw32]F:\>rails -vRails 3.0.5 参照文章:http://thewebfellas.com/blog/2008/11/2/goodbye-attachment_fu...2011-05-13 16:30:46 · 250 阅读 · 0 评论 -
in `require': no such file to load -- readline
在 linux 运行rails c ,报错 in `require': no such file to load -- readline 在http://railsforum.com/viewtopic.php?id=14452 找到解决方法。 >yum install readline-devel 到ruby 的源文件目录: >cd <ruby_...原创 2011-05-18 18:26:56 · 208 阅读 · 0 评论 -
rails的before_filter,如果except子controller中的action skip_filter
如题,在http://stackoverflow.com/questions/2390178/skip-before-filter-in-rails 找到了答案。 问:I have three controllers: dog, cat, and horse.These controllers all inherit from the controller animal...原创 2011-06-09 16:56:54 · 219 阅读 · 0 评论 -
rails3 session配置
Use the database for sessions instead of the cookie-based default, which shouldn't be used to store highly confidential informationCreate the session table withrake db:sessions:create Run th...原创 2011-06-09 19:56:45 · 173 阅读 · 0 评论 -
checking for libxml/parser.h... no
在linux安装 savon 时,遇到这个错误。 yum install libxml2-devel yum install libxslt-devel 之后,再gem install savon 成功! 参考:http://stackoverflow.com/questions/5881156/git-bundle-install-error-with-nokog...原创 2011-12-06 11:41:13 · 334 阅读 · 0 评论