`
luoping0425
  • 浏览: 106403 次
  • 性别: Icon_minigender_2
  • 来自: 赣州
文章分类
社区版块
存档分类
最新评论
文章列表
学习笔记,来自于Programming Ruby 1.9 Ruby 关于Method 一、 定义方法 使用关键字 def 方法名称以小写字母或下划线开头,后面跟着字母、数字和下划线 有的方法名后面跟着?,!或= 方法名有?通常意味着方法返回boolean型结果 例: 1.even? # => false 2.even? # => true 1.instance_of?(Fixnum) # => true 方法名后有!,则此方法的接收者将被修改 方法名后加=,通常意味着赋值 Ruby方法的参数可以设定默认值 def cool_dude(arg1=" ...
使用mini_magick和carrierwave进行图片上传 相关Gem: https://github.com/jnicklas/carrierwave https://github.com/probablycorey/mini_magick 参考实例:https://github.com/diaspora/diaspora/blob/master/app/uploaders/processed_image.rb 示例:用户头像 1. 在项目的Gemfile中添加: gem 'carrierwave' gem 'mini_magick' 然后bundle install ...
http://blog.zool.it/posts/Tasks-plug-in-whenever-the-timing-rails
连接其他主机使用key,登录其他主机时不需要输入用户名、密码 假设   本地IP:127.0.0.1   远程IP:222.222.222.222 操作: 在本地: $ cd ~/.ssh $ ls 查看是否有id_rsa.pub文件,如果不存在则生成公共密钥: $ ssh-keygen -t rsa 在.ssh目录下创建config文件,写入: remote1:   Hostname 222.222.222.222   User remote_user 将id_rsa.pub内容复制到远程主机的.ssh目录下的authorized_keys文件中。 以后连接就可以直接使用ssh remo ...
rails查看路由,使用rake routes 查看单独的路由时,可使用grep 如查看users_controller的相关路由: rake routes | grep users
rails的model中有timestamp,但是有时存储的时间和本地时间不同,需要在config/application.rb中加入: config.active_record.default_timezone = :local 重启之后就可以了
linux中使用date命令来查询当前时间, 时间如果不准确,可以通过ntpdate更新系统时间,具体命令为: ntpdate clepsydra.dec.com 参考:FreeBSD连载(23):配置系统时间--王波  http://unix-cd.com/unixcd12/article_1781.html linux 系统时间/硬件时间--goodluck http://goodluck1982.blog.sohu.com/138950694.html
196: 嵌套模型的form第一部分  http://cn.asciicasts.com/episodes/196-nested-model-form-part-1 197: 嵌套模型的form第二部分 http://cn.asciicasts.com/episodes/197-nested-model-form-part-2
CentOS下: 项目下rails console出错: rails c /usr/local/lib/ruby/1.8/irb/completion.rb:10:in `require': no such file to load -- readline (LoadError) from /usr/local/lib/ruby/1.8/irb/completion.rb:10 from /usr/local/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/commands/console.rb:3:in `require' fr ...
在centos下使用passenger部署,执行gem install passenger,后执行:passenger-install-apache2-module会报安装openssl for ruby. wget http://www.mirrorservice.org/sites/amd64.debian.net/debian/pool/main/libo/libopenssl-ruby/libopenssl-ruby_0.1.4a.orig.tar.gz tar -xzvf libopenssl-ruby_0.1.4a.orig.tar.gz ruby extconf.rb m ...
转载自:http://zhangzhe.heroku.com/blogs/145-zai-CentOS-shang-an-zhuang-Rails-huan-jing 在 CentOS 上 安装 Rails 环境。 1.安装 gcc yum install gcc 2.安装 ruby wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p72.tar.gz tar zxf ruby-1.8.7-p72.tar.gz ./configure make && make install ruby -v ...
1. 首先导出原有数据库,确定原有数据库编码为utf8,导出为/path/to/db1.sql; 2. 创建数据库 create database db1;(注意不需要在此设置数据库编码) 3. source /path/to/db1.sql(注意:路径为绝对路径) 4. 查看数据库编码:show variables like 'charset_set_%'; 5. 如有编码不是utf8,则设置:set names 'utf8'; 6. 设置后重新查看: show variables like 'character_set_%'; +------------------------ ...
http://apidock.com/rails/ActiveRecord/Serialization/to_json   konata.to_json(:include => :posts) # => {"id": 1, "name": "Konata Izumi", "age": 16, "created_at": "2006/08/01", "awesome": true, "po ...
来自于:http://www.hbcms.com/main/dhtml/objects/input_file.html 要使得文件上载能够成功: INPUT type=file 元素必须出现在 FORM 元素内。 必须为 INPUT type=file 元素指定 NAME 标签属性的值。 FORM 元素 method 标签属性的值必须设置为 post 。 FORM 元素 enctype 标签属性的值必须设置为 multipart/form-data(在rails中写法为:html => {:multipart => tru ...
ubuntu下经常我们想要copy一些资源,但是没有移动的存储器,怎么办呢? 1. 查看你和令一台电脑的端口22:nc -zv localhost 22 如果出现connection refused   ubuntu下有可能没有安装ssh 安装:sudo apt-get install openssh-server   Mac: 系统偏好设置->共享->选择“远程登陆” 22端口就可用。 nc -zv localhost 22 Connection to localhost 22 port [tcp/ssh] succeeded! 2.使用命令scp s ...
Global site tag (gtag.js) - Google Analytics