每天一剂Rails良药知识库


未分类文章

每天一剂Rails良药之Authentication

今天我们来看看Rails怎么处理登录认证 虽然Rails有很多登录认证的插件,但是我们可以自己动手丰衣足食 1,db/migrate/001_add_user_table.rb class AddUserTable < ActiveRecord::Migration def self.up create_table :users do |t| t.column :username, :st ...
hideto 评论 (0) 有 1532 人浏览 2011-05-26

每天一剂Rails良药之Safely Use Models in Migrations

我们平时做Migrations时除了更改schema,还经常需要更改data 但我们以前的Migrations可能不工作,因为data之间可能有依赖关系 我们可以通过在Migrations里定义Model来解决该问题: class AddPositionToProducts < ActiveRecord::Migration class Product < ActiveRecord:: ...
hideto 评论 (0) 有 1023 人浏览 2011-05-26

每天一剂Rails良药之Make Dumb Data Smart with composed_of

ActiveRecord有一个composed_of()方法用来声明组件关系,如: class Person < ActiveRecord::Base composed_of :address, :class_name => "Address", :mapping => [%w(address_street street), %w(address_city c ...
hideto 评论 (0) 有 1525 人浏览 2011-05-26

每天一剂Rails良药之DRY Up Your ActiveRecord Code With Scoping

Rails真的是在搜肠刮肚挖空心思想方设法的给代码减肥瘦身,这次我们来看看with_scope方法 class PostsController < ApplicationController before_filter :scope_posts_to_user def show @posts = Post.find(:all) end def create @post = Post.crea ...
hideto 评论 (0) 有 1463 人浏览 2011-05-26

每天一剂Rails良药之Perform Calculations on Your Model Data

ActiveRecord::Calculations模块提供了model级的方法来得到model数据的count,sum,average,maximum和minimum值 例如: Person.count("age > 21") Person.average(:age) Person.minimum(:age) Person.maximum(:age) Person.av ...
hideto 评论 (0) 有 2892 人浏览 2011-05-26

知识库信息

最新评论

不能适应超过三层的的override,比如我有A,B,C三个模板,B在A的基础上添加自己的东西,C在B ...
mingliangfeng 评论了 Rails宝典之第八式: layout与content_for
讲的很清楚,赞
lixinso 评论了 ActionController::Resources + ActiveReso ...
这个插件的下载地址:https://github.com/rails/ssl_requirement
kaogua 评论了 每天一剂Rails良药之ssl_requirement
能评论吗???
refar 评论了 Rails宝典之第五十一式: will_paginate
<%= error_message_on "post", "ti ...
fcp6316 评论了 Rails宝典之第六十五式: Stopping spam
rake db:fixtures:load # Load fixtures into the cur ...
xu_ch 评论了 Rails宝典八十一式:Rails2.0之Fixtures尝 ...
[/b][i][/i][u][/u]引用[color=red][/color][size=medium ...
linjie_830914 评论了 Rails源码研究之ActionController:二,ro ...
并行工程环境的面向成本设计
libiun 评论了 Rails宝典八十五式:YAML配置文件
...
xu_ch 评论了 Rails宝典之第五十七式: Select or Create
你老好了,找的就是他了
xu_ch 评论了 Rails宝典之第七式: layout详解
Global site tag (gtag.js) - Google Analytics