`
wtb
  • 浏览: 103886 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
文章列表
例: ruby 代码map.admin_report 'report/:year',                     :controller => 'admin',                     :action => 'report'   Having this named route in routes.rb tells Rails to create two new methods associated with this route: admin_report_url and hash_for_admin_report_url 则可以如下使用: ruby 代码 ...
ruby 代码 validates_inclusion_of :class_level,          :in => %w( Freshmen Sophomore Junior Senior),         :message=>"must be: Freshmen, Sophomore, Junior, or Senior"     ruby 代码 validates_acceptance_of        validates_associated        val ...
http://www.activescaffold.com/ 三步曲 1、Install the latest version of the plugin: ruby 代码 ./script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold   2、Add this to your layout: ruby 代码         3、Add this to your controller: ruby 代码 active_scaff ...
结合http://marklunds.com/articles/one/311 和手册,完整的一个实现各时区时间转换的一个例子: 首先保证服务器安装tzinfo插件  gem install  tzinfo 1、配置环境 ruby 代码 ActiveRecord::Base.default_timezone = :utc    2、相应的类中 ruby 代码 require 'tzinfo'   3、某模型中有一个字段为time_zone,string类型,用来存储用户设置的他所在的时区 ruby 代码   class User < ActiveReco ...
Show flash messages on cached pages ruby 代码ruby script/plugin install svn://rubyforge.org/var/svn/pivotalrb/cacheable_flash/trunk  时间日历插件http://dry.4thebusiness.com/info/dhtml_calendarruby 代码ruby script/plugin install http://dhtml-calendar.googlecode.com/svn/trunk  ruby 代码 <%= dhtml_calendar_incl ...
根据imagemagick和一些网站的资料,总结了常用的加水印(特别是中文)的代码。 require 'rubygems' require 'RMagick' #在图片中嵌入中文文字 ruby 代码 def   t1       img=Magick::Image.read('path\read_image1.jpg').first    #图片路径,用相对路径即可,相对于public来说的               my_text="\251 这是黑马的标致"             copyright=Magick: ...
puts "在要城在".scan(/./)[0, 6].join('') 注意,用utf-8编码,一个汉字三个字节
migration默认是不支持外键的,原因是一部分数据库如MySQL ISAM和SQLite不支持外键,同时外键也会给Rails的test fixture导入数据造成麻烦(这个好像有个很麻烦的解决办法)。不过还是有个插件提供了外键的导出(rake db:schema:dump)和导入(rake db:schema:load)(可惜migration中无法正常使用)。 <o:p></o:p> 安装: <o:p></o:p> <o:p> </o:p> script/plugin install svn://caboo.se/pl ...
1、<%=select :news,:news_types_id,NewsType.find(:all).map{|c|[c.typename,c.typeid]}%> 实现关联的内容建立选择框,如建新闻的时候把新闻类型取出来,供选择。 2、flash[:error]=@member.errors.full_messages.join('<br/>')  ,把型的错误记录下来   <%=flash_message%> 显示错误
nubyonrails.com/pages/gruff ruby 代码   sudo gem install gruff         # Install the plugin   ./script/plugin install http://topfunky.net/svn/plugins/gruff      # Make a ReportsController and functional test   ./script/generate gruff Reports  
<%form_tag ({:action => 'update',:id => @photo}, :multipart=> true ) do %> 要加上小括号,和大括号,否则,处理有错,另外参数顺序不能错了。,原因在于形参是*方式接受。唉,有时语言太灵活了也痛苦 呀,呵呵。虽然这很简单,手册中也有详细的信息。但还是记下来,因为,ruby/rails中经常因此产生错误。
项目当中,图片上传以及图片的大小调整是经常会用到的一个功能! Rails结合几个plug-in可以说很智能的做到了这一点 1、www.kanthak.net/opensource/file_column/#features 或 ./script/plugin install http://opensvn.csie.org/rails_file_column/plugins/file_column/trunk 2.确保RMagick能正常动行(要安装Imagmagick,Rmagick) 3.建立一个存放路径的model,在数据库中建立Entry数据库 并生成相应的scaffold: ...
snippets.dzone.com/posts/show/389 Sometimes it's nearly impossible to paginate a result set using the built-in :limit and :offset parameters of find(:all). Instead, you can fetch a complicated query and paginate the results afterward. Add the following to application.rb: ruby 代码   def paginat ...
ruby 代码 ruby script/plugin install   http://svn.pragprog.com/Public/plugins/annotate_models   rake annotate_models  
1、安装 gem install -y capistrano 2、自成项目的capistrano控制等相关文件cap --apply-to /path/to/my/app MyApplicationName3、配置环境config/deploy.rb4、配置完了后,执行rake rake remote:exec ACTION=setup然后到远程服务器上看到cpistrano自动创建的几个目录(在这一步常会产生问题,本人在ubuntu下使用,capistrano要使用到openssl,可安装ubuntu的libopenssl-ruby1.8_1.8.5-4ubuntu2_i386.dep包。但是 ...
Global site tag (gtag.js) - Google Analytics