RSS BlogJava-tech.cap-文章分类-rails

我在一望无际的路上
iNeZha robot will deliver the feed updates to your IM or Email in real-time

Delivery Demo of iNezha MSN Robot

Subscribe it
iNezha robot say:
BlogJava-tech.cap-文章分类-rails
Title:rails笔记 ajax
Summary:ajax web2.0 要使用ajax,先要在页面中包含 <%=javascript_include_tag "prototype"%> ajax的指令如下 link_to_remote 例子如下<%... (7/26/2007 8:25:02 PM)
Subscribe it

About "BlogJava-tech.cap-文章分类-rails"

Author:Claim it now
Website:http://www.blogjava.net/cap/category/7192.html
RSS:http://www.blogjava.net/cap/category/7192.html/rss
Update interval:
Last update: 532 days ago
Tags:
Subscribers:1
Shared Subscribers:1
Bookmarked or Shared Articles:0  

Recent contents of "BlogJava-tech.cap-文章分类-rails"

rails笔记 ajax 1080 days ago Read More http://www.blogjava.net/cap/articles/rails_ajax.html
ajax web2.0
要使用ajax,先要在页面中包含 %=javascript_include_tag "prototype"%
ajax的指令如下
link_to_remote
例子如下%= link_to_remote("Do the Ajax thing",
:update = 'mydiv',
:url = { :action = :say_hello }) %...
rails笔记 active controller 1080 days ago Read More http://www.blogjava.net/cap/articles/rails_controller.html
active controller
model指令 提前load model对象 model :Product
基本对应关系
http://xxx.com/admin/hello/list 对应为app/controllers/admin/hello_controller.rb中的list方法如下 module Admin class Hello def list end end end
c...
rails笔记 cache系统 1080 days ago Read More http://www.blogjava.net/cap/articles/rails_cache.html
cache系统 1
cache系统默认只在production下面生效, 要手动生效
修改环境(config/environments)
ActionController::Base.perform_caching=true|false
手动cache
caches_page :xxxaction 直接cache整个页面,相当于html
caches_action :xxxxaction 只...
rails笔记 actionmailer 1080 days ago Read More http://www.blogjava.net/cap/articles/rails_mail.html
actionmailer
rails 内置提供了发送邮件的方法即actionmailer , 在内部使用TMail的api,同时提供了对测试友好的功能,默认在test状态下面,rails不会真正发送mail,只会把mail附加到ActionMailer::Base.deliveries中,这样可以通过测试方法访问了
配置actionmailer
ActionMailer::Base.deli...
rails笔记: webservice 1081 days ago Read More http://www.blogjava.net/cap/articles/rails_webservice.html
web service
创建
先用generator 来创建service 参数为
generator web_service ServiceOne method_a method_b
rails会创建一个service_one_api.rb在/app/apis下,同时有service_one_controller在/app/controllers/下
注意 因为ruby完全动态,所以无法根...
rails笔记: 工具 1081 days ago Read More http://www.blogjava.net/cap/articles/rails_util.html
工具
script
script/server -e development | test | production 切换运行环境 script/generate 支持 Admin::Book 这样的语法, 方便创建子空间 script/console 提供一个包含了当前工程环境的irb(注意运行环境,dev,test,prod)
(以下两个目前在win32下面有bug,不能运行)
scri...
rails笔记: view 1081 days ago Read More http://www.blogjava.net/cap/articles/rails_view.html
view
view分为 builder模式和rhtml模式
builder模式例子如下,rails自带xml.div(:class = "productlist") do
xml.timestamp(Time.now)
@products.each do |product|
xml.product do
xml.productname(product.title)
xml.pri...
rails笔记: 测试 1081 days ago Read More http://www.blogjava.net/cap/articles/rails_test.html
rails 测试
model的测试 = unit test
controller的测试 = functional
unit test
默认所有的Model都产生在 test/unit/xxxx_test.rb
rake clone_structure_to_test #可以把dev中的数据结果自动同步到test的数据中
fixture
数据库不好测试,因为数据是长时间有效的,很难重现,所...
rails笔记 安全和其他 1081 days ago Read More http://www.blogjava.net/cap/articles/rails_maintain.html
SQL injection
默认的rails的 find(xxx) 是过滤了sql 字符串的
但是自己构造condition limit count sql等需要转义,务必使用? 或者:name来传参数,不要直接构造sql
性能配置 fastcgi
timout注意: fastcgi的timeout是强制回收的, 如果一个请求超过timeout会被kill掉 返回500,所以长时间的任务要设...
rails笔记 activerecord 关系 1081 days ago Read More http://www.blogjava.net/cap/articles/rails_relation.html
actuverecord realation
convention 约定
对应关系:
普通对象: Person - people table - person_id
join_table: tablenamea_tablenameb 为table名(按照字母顺序排列)
关系
注意belongs_to对应的表必须有外键, rails认为一个表belongs_to他外键引用的表
one-t...