- 浏览: 234836 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (173)
- ruby (38)
- rails (42)
- javascript (7)
- jquery (1)
- linux (15)
- design patterns (1)
- project management (6)
- IT (7)
- life (19)
- data structures and algorithm analysis (2)
- css (1)
- prototype (1)
- mysql (4)
- html (1)
- git (3)
- novels (1)
- c (1)
- Latex (13)
- erlang (1)
- 求职 (1)
- API (0)
- Shell (4)
- Rabbit MQ (1)
- 计算机基础 (1)
- svn (2)
- 疑问 (1)
最新评论
-
zhangyou1010:
回去倒立去,哈哈。
作为一个程序员,身体很重要! -
Hooopo:
Ruby MetaProgramming is all abo ...
Metaprogramming Ruby -
orcl_zhang:
yiqi1943 写道LZ现在上学还是工作呢工作好多年了。不过 ...
2011年 -
yiqi1943:
LZ现在上学还是工作呢
2011年 -
tjcjc:
query cache
就是一个简单的hash
key就是sq ...
Rails sql延迟加载和自带缓存
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/base.rb
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/attr_internal.rb
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/attribute_accessors.rb
module ActionController #:nodoc: class Base DEFAULT_RENDER_STATUS_CODE = "200 OK" include StatusCodes cattr_reader :protected_instance_variables # Controller specific instance variables which will not be accessible inside views. @@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller @action_name @before_filter_chain_aborted @action_cache_path @_session @_headers @_params @_flash @_response) # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, # and images to a dedicated asset server away from the main web server. Example: # ActionController::Base.asset_host = "http://assets.example.com" @@asset_host = "" cattr_accessor :asset_host # All requests are considered local by default, so everyone will be exposed to detailed debugging screens on errors. # When the application is ready to go public, this should be set to false, and the protected method <tt>local_request?</tt> # should instead be implemented in the controller to determine when debugging screens should be shown. @@consider_all_requests_local = true cattr_accessor :consider_all_requests_local # Indicates whether to allow concurrent action processing. Your # controller actions and any other code they call must also behave well # when called from concurrent threads. Turned off by default. @@allow_concurrency = false cattr_accessor :allow_concurrency # Modern REST web services often need to submit complex data to the web application. # The <tt>@@param_parsers</tt> hash lets you register handlers which will process the HTTP body and add parameters to the # <tt>params</tt> hash. These handlers are invoked for POST and PUT requests. # # By default <tt>application/xml</tt> is enabled. A XmlSimple class with the same param name as the root will be instantiated # in the <tt>params</tt>. This allows XML requests to mask themselves as regular form submissions, so you can have one # action serve both regular forms and web service requests. # # Example of doing your own parser for a custom content type: # # ActionController::Base.param_parsers[Mime::Type.lookup('application/atom+xml')] = Proc.new do |data| # node = REXML::Document.new(post) # { node.root.name => node.root } # end # # Note: Up until release 1.1 of Rails, Action Controller would default to using XmlSimple configured to discard the # root node for such requests. The new default is to keep the root, such that "<r><name>David</name></r>" results # in <tt>params[:r][:name]</tt> for "David" instead of <tt>params[:name]</tt>. To get the old behavior, you can # re-register XmlSimple as application/xml handler ike this: # # ActionController::Base.param_parsers[Mime::XML] = # Proc.new { |data| XmlSimple.xml_in(data, 'ForceArray' => false) } # # A YAML parser is also available and can be turned on with: # # ActionController::Base.param_parsers[Mime::YAML] = :yaml @@param_parsers = {} cattr_accessor :param_parsers # Controls the default charset for all renders. @@default_charset = "utf-8" cattr_accessor :default_charset # The logger is used for generating information on the action run-time (including benchmarking) if available. # Can be set to nil for no logging. Compatible with both Ruby's own Logger and Log4r loggers. cattr_accessor :logger # Controls the resource action separator @@resource_action_separator = "/" cattr_accessor :resource_action_separator # Allow to override path names for default resources' actions @@resources_path_names = { :new => 'new', :edit => 'edit' } cattr_accessor :resources_path_names # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+ # sets it to <tt>:authenticity_token</tt> by default. cattr_accessor :request_forgery_protection_token # Controls the IP Spoofing check when determining the remote IP. @@ip_spoofing_check = true cattr_accessor :ip_spoofing_check # Indicates whether or not optimise the generated named # route helper methods cattr_accessor :optimise_named_routes self.optimise_named_routes = true # Indicates whether the response format should be determined by examining the Accept HTTP header, # or by using the simpler params + ajax rules. # # If this is set to +true+ (the default) then +respond_to+ and +Request#format+ will take the Accept # header into account. If it is set to false then the request format will be determined solely # by examining params[:format]. If params format is missing, the format will be either HTML or # Javascript depending on whether the request is an AJAX request. cattr_accessor :use_accept_header self.use_accept_header = true # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode. class_inheritable_accessor :allow_forgery_protection self.allow_forgery_protection = true # If you are deploying to a subdirectory, you will need to set # <tt>config.action_controller.relative_url_root</tt> # This defaults to ENV['RAILS_RELATIVE_URL_ROOT'] cattr_accessor :relative_url_root self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] # Holds the request object that's primarily used to get environment variables through access like # <tt>request.env["REQUEST_URI"]</tt>. attr_internal :request # Holds a hash of all the GET, POST, and Url parameters passed to the action. Accessed like <tt>params["post_id"]</tt> # to get the post_id. No type casts are made, so all values are returned as strings. attr_internal :params # Holds the response object that's primarily used to set additional HTTP headers through access like # <tt>response.headers["Cache-Control"] = "no-cache"</tt>. Can also be used to access the final body HTML after a template # has been rendered through response.body -- useful for <tt>after_filter</tt>s that wants to manipulate the output, # such as a OutputCompressionFilter. attr_internal :response # Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person" # key. The session will hold any type of object as values, but the key should be a string or symbol. attr_internal :session # Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control # directive. Values should always be specified as strings. attr_internal :headers # Returns the name of the action this controller is processing. attr_accessor :action_name end end
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/attr_internal.rb
class Module # Declares an attribute reader backed by an internally-named instance variable. def attr_internal_reader(*attrs) attrs.each do |attr| module_eval "def #{attr}() #{attr_internal_ivar_name(attr)} end" end end # Declares an attribute writer backed by an internally-named instance variable. def attr_internal_writer(*attrs) attrs.each do |attr| module_eval "def #{attr}=(v) #{attr_internal_ivar_name(attr)} = v end" end end # Declares an attribute reader and writer backed by an internally-named instance # variable. def attr_internal_accessor(*attrs) attr_internal_reader(*attrs) attr_internal_writer(*attrs) end alias_method :attr_internal, :attr_internal_accessor private mattr_accessor :attr_internal_naming_format self.attr_internal_naming_format = '@_%s' def attr_internal_ivar_name(attr) attr_internal_naming_format % attr end end
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/core_ext/module/attribute_accessors.rb
# Extends the module object with module and instance accessors for class attributes, # just like the native attr* accessors for instance attributes. # # module AppConfiguration # mattr_accessor :google_api_key # self.google_api_key = "123456789" # # mattr_accessor :paypal_url # self.paypal_url = "www.sandbox.paypal.com" # end # # AppConfiguration.google_api_key = "overriding the api key!" class Module def mattr_reader(*syms) syms.each do |sym| next if sym.is_a?(Hash) class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} # unless defined? @@pagination_options @@#{sym} = nil # @@pagination_options = nil end # end # def self.#{sym} # def self.pagination_options @@#{sym} # @@pagination_options end # end # def #{sym} # def pagination_options @@#{sym} # @@pagination_options end # end EOS end end def mattr_writer(*syms) options = syms.extract_options! syms.each do |sym| class_eval(<<-EOS, __FILE__, __LINE__) unless defined? @@#{sym} # unless defined? @@pagination_options @@#{sym} = nil # @@pagination_options = nil end # end # def self.#{sym}=(obj) # def self.pagination_options=(obj) @@#{sym} = obj # @@pagination_options = obj end # end # #{" # def #{sym}=(obj) # def pagination_options=(obj) @@#{sym} = obj # @@pagination_options = obj end # end " unless options[:instance_writer] == false } # # instance writer above is generated unless options[:instance_writer] == false EOS end end def mattr_accessor(*syms) mattr_reader(*syms) mattr_writer(*syms) end end
发表评论
-
calendar
2012-02-24 11:04 800http://fullcalendar.vinsol.com/ ... -
ActiveRecord::Dirty
2011-11-21 10:29 742引用Track unsaved attribute chang ... -
TinyTDS
2011-09-20 09:29 781tiny_tds https://github.com/ra ... -
pandoc-ruby
2011-09-11 11:50 1127https://github.com/alphabetum/p ... -
Rails: Calling render() outside your Controllers
2011-04-28 17:15 790From:http://blog.choonkeat.com/ ... -
为什么这样才能装上
2011-02-20 10:39 987引用u2@u2-laptop:~$ sudo gem inst ... -
Rails的transaction
2011-01-07 18:36 3008今天同事问我关于rails transaction,如 ... -
Rails sql延迟加载和自带缓存
2010-12-30 01:11 1555color_lot_manuallies = color_lo ... -
关于rhtml
2010-12-23 00:26 827在视图里有这样一段代码 sorted_op_items = o ... -
will_paginate ajax
2010-11-26 13:21 879两种方法 一, @@pagination_options ... -
save > save!(转)
2010-11-19 19:57 700Thoughtbot folks have a great a ... -
USE INDEX with Active Record finders(转)
2010-11-18 22:07 861可以通过强制指定index的方法优化find MySQL do ... -
html转义
2010-11-17 23:03 911$("#contacts").html(& ... -
Rails HTTP Status Code to Symbol Mapping
2010-11-17 22:40 1579http状态码http://zh.wikipedia.org/ ... -
Scaling Rails很不错的视频
2010-09-29 18:10 801自从railscasts开始讲解rails3后就很久没看了。 ... -
rails源码ActionSupport(待续)
2010-08-31 16:59 897一些奇淫技巧 class Object # An ... -
动态的增加auto_complete
2010-08-30 12:17 844http://www.iteye.com/problems/3 ... -
rails 记录
2010-08-26 15:27 691代码里有这样一句 self.purchase_invoices ... -
用Array来实现OrderedHash
2010-08-18 14:29 877偶然发现电脑的角落里有这样的一段代码.功能是用Array实现的 ... -
rails源码ActiveSupport,待续
2010-08-18 14:10 831rails2.3.2 module ActiveSupport ...
相关推荐
asp.net MVC3相关源码Controller源码
nodejs in action code 源码 源代码
Machine Learning in Action书中源码,里面有书中用到的数据等
9--[小黑点的旅行(未完待续)].zip源码scratch2.0 3.0编程项目源文件源码案例素材源代码9--[小黑点的旅行(未完待续)].zip源码scratch2.0 3.0编程项目源文件源码案例素材源代码9--[小黑点的旅行(未完待续)].zip...
mppt controller_Mpptcontrollercode_mppt_源码.zip
jsm controller调用js源码和dll,可以通过MVC的controller直接调用js的函数
YY多开源码YY多开器源码源码YY多开器源码源码YY多开器源码源码
unity摄像机控制系统源码Camera Controller 3.21 亲测可用,附带官方案例。 完整unitypackage,谢谢研究。 unity摄像机控制系统源码Camera Controller 3.21 Requires Unity 5.1.0 or higher. The perfect AAA ...
zwave 无线通讯协议 PC controller 控制器源码,可以同zwave pc controller 进行串口通信并测试节点-zwave wireless communication protocol PC controller controller source code, can be carried out zwave pc ...
订餐网,外卖网源码,带积分商城,商家系统,外卖网站建设! 系统特点: 周密策划、项目为先 "项目指导技术,技术服从项目",这是我们一贯秉承的原则,也是我们与其他系统开发商、网站建设公司的本质区别所在!我们...
源码01 销售管理系统 源码02 彩票分析系统 源码03 餐饮管理系统 源码04 C#点名程序 源码05 象棋游戏 源码06 变色球游戏 源码07 多功能计算器 源码08 记事本 源码09 简易画图程序 源码10 成绩管理系统 源码11 BBS论坛...
XILINXFPGA源码DDR2 Controller提取方式是百度网盘分享地址
0001-2科技发展有限公司升级版源码 0001科技发展有限公司修正版源码 0002机械配件制造销售公司修正版源码 0003家具地板公司修正版源码 0004-1机械有限公司修正版源码 0004机械有限公司修正版源码 0005机械产品公司...
Applet钢琴模拟程序java源码 2个目标文件,提供基本的音乐编辑功能。编辑音乐软件的朋友,这款实例会对你有所帮助。 Calendar万年历 1个目标文件 EJB 模拟银行ATM流程及操作源代码 6个目标文件,EJB来模拟银行ATM...
controller-hub-源码.rar
IOS应用源码——tab bar controller 自定义颜色和演示demo.zip
经典成品网站非常漂亮的个人博客网站源码非常漂亮的个人博客网站源码非常漂亮的个人博客网站源码非常漂亮的个人博客网站源码
java HttpServletRequest HttpServletResponse 源码 request response
0001-2科技发展有限公司升级版源码 0001科技发展有限公司修正版源码 0002机械配件制造销售公司修正版源码 0003家具地板公司修正版源码 0004-1机械有限公司修正版源码 0004机械有限公司修正版源码 0005机械产品公司...
0001-2科技发展有限公司升级版源码 0001科技发展有限公司修正版源码 0002机械配件制造销售公司修正版源码 0003家具地板公司修正版源码 0004-1机械有限公司修正版源码 0004机械有限公司修正版源码 0005机械产品公司...