在config/environment.rb/development.rb或者config/environment/production.rb中, 简单示范例子: Text03::Application.configure do …… config.action_mailer.delivery_method =:smtp config.action_mailer.smtp_settings = { :address=> "smtp.qq.com", :port=> 25,…
 FROM:http://blog.163.com/zjc_8886/blog/static/2408175201011222590967/ 实现方法: 由于ckeditor中的"上传图片""上传文件""上传FLASH” 三个功能中都有“浏览服务器”按钮,所以我们要修改3个JS文件,先打开ckeditor文件夹中的ckeditor\plugins\image\dialogs\image.js文件,CTRL+F,搜索"browseServer”,找…
基于rails4.0环境 当使用Ckeditor上传中文命名图片时报错,解决方法是对图片进行重命名 在Ckeditor插件的安装目录下找到controllers/.../application.rb 比如:E:\RailsInstaller\Ruby1.9.3\lib\ruby\gems\1.9.1\gems\ckeditor-4.0.4\app\controllers\ckeditor\application.rb 然后找到 def respond_with_asset(asset) def…
今天coding的时候遇到一个未知的类型,于是用puts logo_params.class查了下数据类型,然后google了一下发现是 Strong Parameter Strong parameters机制是rails4.0新引入的. 接下来我们看看它的用法:(简单例子) rail3.0是这样的:使用Mass assignment方法 # app/models/user.rb class User < ActiveRecord::Base attr_accessible :username,…
     Paperclip -- 上传中文命名图片 使用Paperclip和ImageMagick插件来处理图片的时候,上传非中文命名的图片时,只要把配置写好就没问题 if you need to add image attachments to a model? See how with paperclip in this episode 创建model方法可以借鉴 :http://www.cnblogs.com/lmei/p/3231268.html 在model中进行配置 # 简单例子…
 在route中进行修改,添加下面代码 namespace :mycontroller do get 'mymethod' , :on=> :member end end 注: :on => :member照写,不是变量来的... 这样就可以使用mymethod_mycontroller_path.over~~ @_@!!…
在开发阶段,如果发生错误时,都会出现错误提示页面,比如:RecordNotFound之类的,虽然这些错误方便开发进行debug,但是等产品上线时,如果还是出现这些页面,对于用户来说是很不友好的. 所以必须定制错误跳转到404和500 下面示范在development下开发的404和500跳转: 首先在 config/environment/development.rb中,找到下面这句代码,将其设为false config.consider_all_requests_local = false #…
学习链接:http://rubyer.me/blog/583/ RESTful风格的路由动词默认有7个(分别为:index, show, create, new, edit, update, destroy). 有时我们需要自定义路由,这时就要用到:on参数.:on参数有三种取值,分别为collection,member,new. 如果想添加一个member方式的路由,可以这样: resources :photos do member do get 'preview' end end 将会添加一…
最近配置production环境,找了好几份文档,从傻逼到苦逼~~终于配置成功~~@_@!!! 首先,先加载以下几个插件: # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0'# Use jquery as the JavaScri…
基于rails4.0环境 Rails 页面缓存的方法很多,最近弱弱地尝试了fragment cache,用法还算简单~@_@|| 首先,查看config/environment/production.rb config.action_controller.perform_caching = true 确保上面代码是true状态. fragment cache是用来对页面进行片段缓存的,首先在你需要缓存的页面加上两行代码,示例如下: <!-- views/test/index --> <%…