- 浏览: 7702 次
- 性别:
- 来自: 济南
最近访客 更多访客>>
最新评论
-
timezz:
rails2.0以后inplaceedit应该就不是自带的而是 ...
In-Place-editing 下拉列表 -
tes:
应该和数据库配合使用,是不是没有配合数据库啊和in_place ...
In-Place-editing 下拉列表 -
winfield:
<div class="quote_title ...
In-Place-editing 下拉列表 -
luodongju325:
出错:undefined method `in_place_e ...
In-Place-editing 下拉列表 -
liuqiang:
写的不错,show下效果吧:)
In-Place-editing 下拉列表
文章列表
Make Dumb Data Smart with composed_of() 通过composed_of() 使呆板的数据变聪明
基本语法如下
class SomeModel < ActiveRecord::Base
composed_of :some_attribute,
#要添加功能的SomeModel的属性名,
#这个属性可以随便起个名不一定是SomeModel 表中的属 ...
- 2008-07-24 13:44
- 浏览 642
- 评论(0)
Dynamically Configure Your Database 动态的设置你的数据库
有时候不同的操作系统连接数据库的套接字段设置是不同的 如果不同的服务器操作系统不同就需要更改database.yml比较麻烦
但是在database.yml做如下修改就可以避免这个麻烦
development:
adapter: mysql
database: DynamicDatabaseConfiguration_development
username: root
password:
socket: <%= ["/tmp/mysqld.sock" ,
&q ...
- 2008-07-24 13:06
- 浏览 675
- 评论(0)
Add Behavior to Active Record Associations
先贴上数据迁移代码
class AddStudentsTables < ActiveRecord::Migration
def self.up
create_table :students do |t|
t.column :name, :string
t.column :graduating_year, :integer
end
create_table :grades do |t|
t.column :student_id, :integer
t.column :score, :in ...
- 2008-07-24 12:54
- 浏览 968
- 评论(0)
Polymorphic Associations—has_many :whatevers Problem
《Rails cookbook》中有一节和这一章类似
通过表中特定的属性区别不同模型的数据实现多态
数据库代码
class AddPeopleCompanyAndAddressTables < ActiveRecord::Migration
def self.up
create_table :people do |t|
t.column :name, :string
end
create_table :companies do |t|
t.column :name, : ...
- 2008-07-23 21:10
- 浏览 860
- 评论(0)
Many-to-Many Relationships with Extra Data 带有数据的多对多关系
一般多对多关系都带有 一个存储关系的表 这表一般用处比较单一 但是有时也需要在这个表中添加除关系以外的数据 下面有个订杂志的例子
一般情况下
def self.up
create_table :magazines do |t|
t.column :title, :string
end
create_table :readers do |t|
t.column :name, :string
end
create_table :magazines_readers, :id = ...
- 2008-07-23 20:53
- 浏览 1106
- 评论(0)
Recipe 17 DRY Up Your Database Configuration
一般设置数据库database.yml:
development:
adapter: mysql
database: DRYUpYourDatabaseConfig_development
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql
database: DRYUpYourDatabaseConfig_test
username: root
password:
socket: /t ...
- 2008-07-23 19:55
- 浏览 795
- 评论(0)
前几日再看《Rails Cookbook》时有一章叫‘Processing Dynamically Created Input Fields’处理动态创建的输入项(大概是这么翻译吧)觉得挺好可以在以后当作用户权限或角色设置来用。于是实际练了一下但发现一个错误
先把源码发一下,再把错误用有注释标出来
db/schema.rb:
ActiveRecord::Schema.define(:version => 0) do
create_table "roles", :force => true do |t|
t.column "n ...
- 2008-07-23 19:30
- 浏览 970
- 评论(0)
rails自带In-Place文本编辑,但是我一直想弄一个In-Place的下拉列表前几天在看《Rails Recipes》的时候看见有这么一篇文章,但是试过之后发现在ie下不能正常显示
注释上说是innerhtml的问题。周末在网上搜索了几个解决办法。把自己的实现过程列下来。
js代码放在public文件夹下命名为in_place_select_editor.js
Ajax.InPlaceSelectEditor = Class.create();
Object.extend(Object.extend(Ajax.InPlaceSelectEditor.prototype, Ajax.I ...