- 浏览: 163945 次
- 性别:
- 来自: 杭州
文章分类
最新评论
-
GunChin:
有些复杂,看得不是很懂
RAILS -
shellfish:
恩,红帽默认的SELinux的级别是强制,这个一般我不大用,装 ...
华思服务器一个奇怪问题的解决方法 -
机器人:
你说得太好了了了了了了了 子 啊啊啊啊,呼啦啦。
GIT handbook -
hbxiao135:
能介绍下 fat free crm的 流程分析吗?
(CRM)customer relationship management sysetm
1.file_column git clone git://github.com/activescaffold/file_column.git gem install rmagick model: file_column :photo, :magick => { :versions => { "thumb" => "100x100>", "medium" => "640x480>" } } view: <%= image_tag(url_for_file_column('profile', 'photo', 'thumb')) if @profile && @profile.photo %><%= file_column_field 'profile', 'photo' %> web example: Attention: I will be speaking at the Canada on Rails conference, which will be held on April 13th-14th in Vancouver, Canada. David Heinemeier-Hansson will be giving a keynote and there are a lot of other big names on the list of speakers. I'm honored to give a talk about file_column and developing plugins in general. This library makes handling of uploaded files in Ruby on Rails as easy as it should be. It helps you to not repeat yourself and write the same file handling code all over the place while providing you with nice features like keeping uploads during form redisplays, nice looking URLs for your uploaded files and easy integration with RMagick to resize uploaded images and create thumb-nails. Files are stored in the filesystem and the filename in the database. Example As you can judge a library best by looking at how to use it, here is a short example: Just make the "image" column ready for handling uploaded files... class Entry < ActiveRecord::Base file_column :image end ... generate file fields that keep uploaded images during form redisplays to your view... <%= file_column_field "entry", "image" %> ... and display uploaded images in your view: <%= image_tag url_for_file_column("entry", "image") %> It's just as easy! Why should it be any more difficult for a Rails application? So what about the RMagick integration? Have a look: To resize every uploaded image to a maximum size of 640x480, you just have to declare an additional option. class Entry < ActiveRecord::Base file_column :image, :magick => { :geometry => "640x480>" } end You can even automatically create versions in different sizes that have nice filenames... class Entry < ActiveRecord::Base file_column :image, :magick => { :versions => { "thumb" => "50x50", "medium" => "640x480>" } } end ... and display them in your view: <%= image_tag url_for_file_column("entry", "image") %> 值得注意的是,如果你用在其他的页面显示这张图片,必须存在这个实例变量@xxx eg. <% @profiles.each do |@profile|%> <%= image_tag(url_for_file_column('profile', 'photo', 'thumb')) if @profile.photo %> end bug: uninitialized constant FileColumn::ClassMethods::Inflector solution: go to file_column.rb go to line 619 add “ActiveSupport::” before “Inflector.underscore(self.name).to_s,” to give => “ActiveSupport::Inflector.underscore(self.name).to_s,”
发表评论
-
actionmailer发送邮件失败的问题解决记录
2011-05-24 14:12 2334我们公司的WLAN网管采用ruby on rails架构,同时 ... -
ROR rake
2009-10-20 14:05 1046原文: Ruby on Rails Rake Tuto ... -
控制器内部对请求的操作
2009-10-20 13:41 1843控制器内部对请求的操作 一Action方法 1 ... -
在rails环境中直接执行sql语句而不需要创建MODEL
2009-09-23 10:54 2987标准格式是:ActiveRecord::Base.connec ... -
6 Steps To Refactoring Rails (for Mere Mortals)
2009-07-31 11:26 866Since December, Rails ... -
rails 中简单的创建保存一条信息
2009-07-20 09:43 717Securitylog.new( # :ses ... -
uninstall all gems
2009-07-14 11:31 876GEMS=`gem list --no-versions` ... -
rails 拖拉排序效果demo
2009-06-30 10:55 1353要為Ruby on Rails程式加入拖曳排 ... -
something about with_scope
2009-06-23 10:53 1164今天看了一点关于with_scope的知识,有点感觉,写点东西 ... -
Add jQuery datagrids to your Rails applications
2009-06-03 10:39 1521Add jQuery datagrids to your Ra ... -
Multiple Attachments in Rails
2009-06-03 10:19 1822Multiple Attachments in Rails ... -
REST on Rails之自定义路由
2009-06-03 10:03 1685REST on Rails之自定义路由 from L ... -
自定义will_paginage输出
2009-06-03 09:55 786自定义will_paginage输出 from Le ... -
Rails Cookie测试
2009-06-03 09:48 1077Rails Cookie测试 from Le ... -
配置ActionMailer使用GMail发送邮件
2009-06-03 09:45 1453配置ActionMailer使用GMail发送邮件 ... -
rails 记住跳转前的url
2009-06-02 13:44 1381def store_location ses ... -
给Non-ActiveRecord Objects进行validate
2009-06-02 09:33 886对于非ActiveRecord对象的Validation,我们 ... -
cookie + js动态修改iframe 父窗口的链接参数
2009-04-21 18:12 2870取得 由于最近自己做的项目中采用了目前较为流行的经典左右结构 ... -
git 冲突解决
2009-04-21 17:57 5169比较笨的办法就是直接改本地的代码 先git pull ,他 ... -
git 下gw来查看团队的修改
2009-04-07 15:46 856首先开启一个命令行,在命令行中输入 alias gw= ...
相关推荐
在Android开发中,调用系统照相机、相册以及上传图片是常见的功能需求,尤其在社交应用、生活服务类应用中十分常见。本教程将详细讲解如何实现这些功能。 一、调用系统照相机 1. 添加权限:首先在AndroidManifest....
例如,`ImagePicker.getImage(source: ImageSource.camera)`会打开相机让用户拍摄照片。 2. **选择相册** 同样利用`image_picker`库,可以选择从用户的设备相册中选取图片。只需将`source`参数设置为`ImageSource....
在Android平台上,文件上传和将数据写入数据库是常见的任务,尤其在开发涉及用户交互的应用时,例如照片分享、文档管理或云同步等场景。本文将深入探讨如何在Android环境中实现这两个功能。 首先,让我们讨论文件...
在安卓平台上,用户经常需要进行拍照或从图库选择图片并上传到服务器。这个功能在社交应用、在线购物、文档管理等许多类型的App中都十分常见。本篇将详细讲解如何实现这一功能。 首先,我们需要了解安卓系统提供的...
用户可能需要从相机拍摄新照片或从图库选择已有图片进行编辑、上传等操作。本篇将详细介绍如何实现这一功能。 首先,我们需要在AndroidManifest.xml文件中添加必要的权限,以便访问相机和外部存储: ```xml ...
在Web开发中,用户经常需要上传图片,如个人头像、产品照片或文章配图等。传统的单文件上传方式已经不能满足现代网站的需求,因此,多图片上传功能应运而生。这个"多图片上传Upload网页源码"提供了一个实用的解决...
不过明确的是编写那样的代码有多简单,购买它们会有多昂贵以及它们需要多么昂贵和强大的硬件。如果你有什么中立的观点(比如说没有被SUN和Microsoft的百万美金所影响),请顺便通知我。 据我所知,JSP基于Java,...
在本例中,上传组件的显示是根据父组件传递过来的`columnName`变量动态控制的,这意味着我们可以在一个页面上根据不同的需求展示不同类型文件的上传控件。通过`v-show`或`v-if`指令,我们可以根据条件来决定是否显示...
在Android应用开发中,调用系统相机和系统相册是常见的功能需求,用户可以通过这些功能拍摄新照片或选择已有的图片。本教程将详细介绍如何实现这两个功能,并讲解如何更改图片的保存路径,以及如何实现点击图片查看...
在Android应用开发中,用户经常需要从图库中选择照片以进行各种操作,例如上传、编辑或显示。本文将详细讲解如何实现这个功能,并提供相关的代码示例。 首先,为了访问设备的外部存储(如SD卡)以获取图库中的照片...
using (System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open)) { return System.Drawing.Image.FromStream(fs); } } ``` 在这个方法中,我们使用了`using`语句确保文件流在使用...