diff options
Diffstat (limited to 'railties/guides')
4 files changed, 42 insertions, 13 deletions
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb index bd25111405..6a41bde9f6 100644 --- a/railties/guides/rails_guides/generator.rb +++ b/railties/guides/rails_guides/generator.rb @@ -1,11 +1,5 @@ require 'set' -class String - def html_safe! - self - end unless "post 9415935902f120a9bac0bfce7129725a0db38ed3".respond_to?(:html_safe!) -end - module RailsGuides class Generator attr_reader :output, :view_path, :view, :guides_dir @@ -61,7 +55,7 @@ module RailsGuides body = set_header_section(body, @view) body = set_index(body, @view) - result = view.render(:layout => 'layout', :text => textile(body).html_safe!) + result = view.render(:layout => 'layout', :text => textile(body).html_safe) f.write result warn_about_broken_links(result) if ENV.key?("WARN_BROKEN_LINKS") end @@ -77,8 +71,8 @@ module RailsGuides header = textile(header) - view.content_for(:page_title) { page_title.html_safe! } - view.content_for(:header_section) { header.html_safe! } + view.content_for(:page_title) { page_title.html_safe } + view.content_for(:header_section) { header.html_safe } new_body end @@ -109,7 +103,7 @@ module RailsGuides index << '</ol>' index << '</div>' - view.content_for(:index_section) { index.html_safe! } + view.content_for(:index_section) { index.html_safe } i.result end diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 562bc76135..fb4c42f118 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -496,7 +496,42 @@ The class method +delegate+ h3. Extensions to +Class+ -h4. Class Attribute Accessors +h4. Class Attributes + +The method +Class#class_attribute+ declares one or more inheritable class attributes that can be overriden at any level down the hierarchy: + +<ruby> +class A + class_attribute :x +end + +class B < A; end + +class C < B; end + +A.x = :a +B.x # => :a +C.x # => :a + +B.x = :b +A.x # => :a +C.x # => :b + +C.x = :c +A.x # => :a +B.x # => :b +</ruby> + +For example that's the way the +allow_forgery_protection+ flag is implemented for controllers: + +<ruby> +class_attribute :allow_forgery_protection +self.allow_forgery_protection = true +</ruby> + +For convenience +class_attribute+ defines also a predicate, so that declaration also generates +allow_forgery_protection?+. Such predicate returns the double boolean negation of the value. + +NOTE: Defined in +active_support/core_ext/class/attribute.rb+ The macros +cattr_reader+, +cattr_writer+, and +cattr_accessor+ are analogous to their +attr_*+ counterparts but for classes. They initialize a class variable to +nil+ unless it already exists, and generate the corresponding class methods to access it: diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index 7dfcf4a507..5f324ece60 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -87,7 +87,7 @@ <div id="container"> <div class="wrapper"> <div id="mainCol"> - <%= yield.html_safe! %> + <%= yield.html_safe %> </div> </div> </div> diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile index fc178fa44b..579b1a5538 100644 --- a/railties/guides/source/rails_application_templates.textile +++ b/railties/guides/source/rails_application_templates.textile @@ -88,7 +88,7 @@ Please note that you need to +git :init+ before you can install a plugin as a su Or use plain old SVN : <ruby> -plugin 'wtfsvn', :svn => 'svn://crap.com/wtf/trunk' +plugin 'usingsvn', :svn => 'svn://example.com/usingsvn/trunk' </ruby> h4. vendor/lib/file/initializer(filename, data = nil, &block) |