- 浏览: 243086 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (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 875http://fullcalendar.vinsol.com/ ... -
ActiveRecord::Dirty
2011-11-21 10:29 787引用Track unsaved attribute chang ... -
TinyTDS
2011-09-20 09:29 856tiny_tds https://github.com/ra ... -
pandoc-ruby
2011-09-11 11:50 1207https://github.com/alphabetum/p ... -
Rails: Calling render() outside your Controllers
2011-04-28 17:15 832From:http://blog.choonkeat.com/ ... -
为什么这样才能装上
2011-02-20 10:39 1044引用u2@u2-laptop:~$ sudo gem inst ... -
Rails的transaction
2011-01-07 18:36 3056今天同事问我关于rails transaction,如 ... -
Rails sql延迟加载和自带缓存
2010-12-30 01:11 1611color_lot_manuallies = color_lo ... -
关于rhtml
2010-12-23 00:26 870在视图里有这样一段代码 sorted_op_items = o ... -
will_paginate ajax
2010-11-26 13:21 912两种方法 一, @@pagination_options ... -
save > save!(转)
2010-11-19 19:57 754Thoughtbot folks have a great a ... -
USE INDEX with Active Record finders(转)
2010-11-18 22:07 891可以通过强制指定index的方法优化find MySQL do ... -
html转义
2010-11-17 23:03 954$("#contacts").html(& ... -
Rails HTTP Status Code to Symbol Mapping
2010-11-17 22:40 1623http状态码http://zh.wikipedia.org/ ... -
Scaling Rails很不错的视频
2010-09-29 18:10 823自从railscasts开始讲解rails3后就很久没看了。 ... -
rails源码ActionSupport(待续)
2010-08-31 16:59 934一些奇淫技巧 class Object # An ... -
动态的增加auto_complete
2010-08-30 12:17 895http://www.iteye.com/problems/3 ... -
rails 记录
2010-08-26 15:27 750代码里有这样一句 self.purchase_invoices ... -
用Array来实现OrderedHash
2010-08-18 14:29 915偶然发现电脑的角落里有这样的一段代码.功能是用Array实现的 ... -
rails源码ActiveSupport,待续
2010-08-18 14:10 884rails2.3.2 module ActiveSupport ...
相关推荐
【标题】"Controller源码"涉及的是ASP.NET MVC3框架中的关键组件——Controller类的源代码分析。在ASP.NET MVC3中,Controller是应用程序的主要控制层,负责处理来自客户端的请求,协调应用逻辑,并返回相应的视图...
9--[小黑点的旅行(未完待续)].zip源码scratch2.0 3.0编程项目源文件源码案例素材源代码9--[小黑点的旅行(未完待续)].zip源码scratch2.0 3.0编程项目源文件源码案例素材源代码9--[小黑点的旅行(未完待续)].zip...
Spark-2.3.1源码解读。 Spark Core源码阅读 Spark Context 阅读要点 Spark的缓存,变量,shuffle数据等清理及...PIDController源码赏析及 back pressure 实现思路 Streaming Context重点摘要 checkpoint 必知必会
这是我收集的10个图书管理系统的源码。各个系统实现的编程语言可能不同,有VB、VC、C#、C++、asp、php等等,有的系统功能比较复杂,有的比较简单。有的系统不仅包括源码和数据库,而且包括论文等设计文档。10个系统...
unity摄像机控制系统源码Camera Controller 3.21 亲测可用,附带官方案例。 完整unitypackage,谢谢研究。 unity摄像机控制系统源码Camera Controller 3.21 Requires Unity 5.1.0 or higher. The perfect AAA ...
订餐网,外卖网源码,带积分商城,商家系统,外卖网站建设! 系统特点: 周密策划、项目为先 "项目指导技术,技术服从项目",这是我们一贯秉承的原则,也是我们与其他系统开发商、网站建设公司的本质区别所在!我们...
本资源包含2000套微信小程序的源码,对于开发者来说是一份宝贵的参考资料,可以用来学习、研究或者作为开发新项目的起点。 源码下载是开发者获取程序原始代码的方式,对于学习和理解编程逻辑至关重要。这些微信小...
3. **MVC模式**:考虑到源码的动态更新功能,它可能采用了Model-View-Controller(MVC)设计模式。这是一种将业务逻辑、数据处理和界面显示分离的方式,有助于提高代码可维护性和可扩展性。 4. **前端技术**:尽管...
ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh框架项目源码ssh...
6. **Mvcmediaplayer**:这可能是主要的项目源代码,基于MVC(Model-View-Controller)架构设计。MVC模式是一种常见的软件设计模式,用于分离业务逻辑、用户界面和数据模型。在视频播放网站中,模型负责处理数据,...
源码01 销售管理系统 源码02 彩票分析系统 源码03 餐饮管理系统 源码04 C#点名程序 源码05 象棋游戏 源码06 变色球游戏 源码07 多功能计算器 源码08 记事本 源码09 简易画图程序 源码10 成绩管理系统 源码11 BBS论坛...
jQuery in Action 及 源码 src 2
0001-2科技发展有限公司升级版源码 0001科技发展有限公司修正版源码 0002机械配件制造销售公司修正版源码 0003家具地板公司修正版源码 0004-1机械有限公司修正版源码 0004机械有限公司修正版源码 0005机械产品公司...
移动医疗APP源码是开发医疗健康应用的核心组成部分,它包含了应用程序的所有逻辑和界面设计。在Android平台上,这种源码通常是用Java或Kotlin语言编写的,并使用Android Studio作为集成开发环境(IDE)。在这个案例...
《cocos creator完整麻将源码解析与开发指南》 cocos Creator是一款强大的2D游戏开发引擎,被广泛应用于游戏开发,尤其是休闲娱乐类游戏,如麻将。本篇将深入探讨"麻将源码"这一主题,结合cocos Creator的特性,为...
XILINXFPGA源码DDR2 Controller提取方式是百度网盘分享地址
【产品展示网站源码】是一种用于在线展示公司产品的软件代码,它构成了一个网站的基础结构,允许企业以有吸引力的方式向访客展示其商品或服务。此类源码通常包含前端和后端组件,前者负责用户界面的设计和交互,后者...
Linux系统下的DHCP(Dynamic Host Configuration Protocol)源码解析 DHCP是一种网络协议,用于自动分配IP地址、子网掩码、默认网关等网络配置信息给网络中的设备。在Linux环境中,DHCP服务器通常使用isc-dhcp-...
【标题】:“多功能在线报价系统源码” 在线报价系统是一种基于网络的应用程序,它使得企业或个人能够方便快捷地提供产品或服务的价格信息给潜在客户。这个“多功能在线报价系统源码”是专为此目的设计的,允许用户...
为方便阅读,把blog上的libevent源码深度剖析系列文章整合成一个pdf。