F - Rails】的更多相关文章

There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned…
回想Rails --Active Record Query Interface--Scopes的基本用法: 1.Passing in arguments.例子:scope  :name , -> {order("..")} 2.Using conditionals.             scope :name, -> {where(...)} 单词:migrate: 1. if people migrate, they go to live in another are…
查询数据操作…
1 form_for方法是ActionView::Helpers::FormHelper模块内的方法,所以可以在ActionView的实例中直接调用 2 from_for方法的原型为form_for(record, options = {}, &block),其中record可以是字符串和符号,这时,参数通过params[string/:symbol][:field]传递:record也可以是示例对象,这时参数通过params[instance.class.lowercase][:field]传…
http://ruby-toolbox.com/ ~/.gemrc --- :backtrace: false :benchmark: false :bulk_threshold: 1000 :sources: - http://ruby.taobao.org :update_sources: true :verbose: true gem: --no-document --no-ri 安装本地包 gem install --local C:\rubygems-update-2.2.3.gem…
http://api.rubyonrails.org/classes/ActiveRecord/Enum.html 新的项目中有一个字段是展示类型,可以用下拉框去做,用string存储具体的类型字段. 尝试了一下把展示类型修改为integer,用Rails enum枚举来做. 使用枚举(整型)来存储类似于下拉框选择的这类的值, 比起直接存储类型的字符串,能减少表中存储字段的大小. 建表语句如下 class CreateSubjects < ActiveRecord::Migration[5.0]…
一:安装Ruby 1.在http://rubyinstaller.org 下载需要的ruby版本,因为是exe文件,所以,你可以直接安装. 安装结束后,cmd上运行 ruby -v 显示版本号.如果正常显示Ruby版本号,表示安装成功.…
之前在rails开发中使用了ckeditor作为可视化编辑器,不过感觉ckeditor过于庞大,有很多不需要的功能,而且图片上传功能不好控制不同用户可以互相删除图片,感觉很不好.于是考虑更改可视化编辑器,多方考虑选择了bootstrap3-wysiwyg,但是这个编辑器无法实现图片上传功能,还有换行使用br而不是p标签不是很好.于是考虑自定义完善其功能. 个人原创,版权所有,转载请注明原文出处,并保留原文链接: https://www.embbnux.com/2015/03/17/rails_u…
原文地址: http://guides.ruby-china.org/layouts_and_rendering.html Rails 布局和视图渲染 本文介绍 Action Controller 和 Action View 中布局的基本功能. 读完本文,你将学到: 如何使用 Rails 内建的各种渲染方法: 如果创建具有多个内容区域的布局: 如何使用局部视图去除重复: 如何使用嵌套布局(子模板): Chapters 概览:各组件之间的协作 创建响应 渲染视图 使用 render 方法 使用 r…
这里简单加上几个验证,非空,最小长度,唯一 修改模型 修改app/models/post.rb文件,如下: class Post < ActiveRecord::Base #attr_accessible :title, :content validates :title, :context, :presence => true validates :title, :length => { :minimum =>2} validates :title, :uniqueness =&…