`
文章列表
Source: http://database.51cto.com/art/200912/168453.htm explain显示了mysql如何使用索引来处理select语句以及连接表。可以帮助选择更好的索引和写出更优化的查询语句。 使用方法,在select语句前加上explain就可以了: 如: explain select surname,first_name form a,b where a.id=b.id EXPLAIN列的解释: table:显示这一行的数据是关于哪张表的 type:这是重要的列,显示连接使用了何种类型。从最好到最差的连接类型为const、eq_reg、 ...
在使用find_or_create_by_这个动态属性时,发现Rails API文档里有个错误. 文档里给出的例子如下: # Now 'Bob' exist and is an 'admin' User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true } 能看出应该是查找name为Bob的记录,不存在就创建一个name为Bob, age为40的admin, 但我用类似的方法测试,发现不起做用, age会为nil, 将代码改为 # Now 'Bob' exist and is an 'ad ...
Source: http://d.strelau.net/post/163547069/remove-div-fieldwitherrors-from-rails-forms In a decision I have never understood, Rails forms by default add <div class="fieldWithErrors"> ... </div> around any field in your form that has validation errors on submission. Which sucks ...
从网上抄来的,先做个标记: MyISAM :这个是默认类型,它是基于传统的ISAM类型,ISAM是Indexed Sequential Access Method (有索引的顺序访问方法) 的缩写,它是存储记录和文件的标准方法.与其他存储引擎比较,MyISAM具有检查和修复表格的大多数工具. MyISAM表格可以被压缩,而且它们支持全文搜索.它们不是事务安全的,而且也不支持外键。如果事物回滚将造成不完全回滚,不具有原子性。如果执行大量 的SELECT ,MyISAM是更好的选择。 InnoDB :这种类型是事务安全的.它与BDB类型具有相同的特性,它们还支持外键.InnoDB表格速度很快.具 ...
xml.erb gone, xml.builder in Controllers def show @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml # show.xml.builder end end Views show.xml.builder xml.instruct! xml.user do xml.login(@user.login, :type => :string) x ...
Global site tag (gtag.js) - Google Analytics