Skip to content

Commit

Permalink
Merge remote-tracking branch 'rails/3-1-stable' into asset_urls
Browse files Browse the repository at this point in the history
* rails/3-1-stable: (68 commits)
  Revert changes done in c56618e, 51cb745 and 030950a. The links are pointing to files/*/*.html for usage in api.rubyonrails.org and as a result are broken in GitHub blobs. This is unavoidable (at least for now).
  copy-edits 7c2db6c, cbf2af1, and f391f94
  Added 'Configuring Assets' section to configuring guide
  Update remove_index documentation
  Typo.
  minor clean up generators section
  add info that plugin installs need git or svn installed
  document doc:* rake tasks
  typo changes fixed
  fixed typo chnages
  add details on how to use specific annotations in rake:notes
  document how rake notes work
  The name for the plain text template in Rails3 appears to be method.text.erb, not, method.text.plain.erb.  Updated the doc to reflect this change.  Also fixed a reference to an example that was incorrect.
  form => form_for
  Tweak linebreak in ActionController::Redirecting doc
  Updated rails´s guides on the config.serve_static_assets and it´s settings in production mode using WEBrick. This documentation has it´s roots in #issue1657. You have to set config.serve_static_assets to true in production mode with WEBrick as only this includes ActionDispatch::Static.
  Improve documentation around status code argument of redirect_to
  minor copy edit 0bdeddb
  Jruby => JRuby, Mysql => MySQL
  Moving hint down. As required after all database examples.
  ...
  • Loading branch information
chriseppstein committed Jun 18, 2011
2 parents ad16115 + 7e65b00 commit a223363
Show file tree
Hide file tree
Showing 40 changed files with 451 additions and 179 deletions.
19 changes: 10 additions & 9 deletions Gemfile
@@ -1,4 +1,4 @@
source 'http://rubygems.org'
source "http://rubygems.org"

gemspec

Expand Down Expand Up @@ -35,27 +35,28 @@ end

platforms :mri_19 do
# TODO: Remove the conditional when ruby-debug19 supports Ruby >= 1.9.3
gem "ruby-debug19", :require => 'ruby-debug' if RUBY_VERSION < "1.9.3"
gem "ruby-debug19", :require => "ruby-debug" if RUBY_VERSION < "1.9.3"
end

platforms :ruby do
if ENV["RB_FSEVENT"]
gem 'rb-fsevent'
gem "rb-fsevent"
end
gem 'json'
gem 'yajl-ruby'
gem "json"
gem "yajl-ruby"
gem "nokogiri", ">= 1.4.4"

group :test do
gem 'ruby-prof'
gem "ruby-prof" if RUBY_VERSION < "1.9.3"

end
# AR
gem "sqlite3", "~> 1.3.3"

group :db do
gem "pg", ">= 0.11.0"
gem "mysql", ">= 2.8.1"
gem "mysql2", ">= 0.3.0"
gem "mysql2", ">= 0.3.6"
end
end

Expand All @@ -78,10 +79,10 @@ end
# gems that are necessary for ActiveRecord tests with Oracle database
if ENV['ORACLE_ENHANCED_PATH'] || ENV['ORACLE_ENHANCED']
platforms :ruby do
gem 'ruby-oci8', ">= 2.0.4"
gem "ruby-oci8", ">= 2.0.4"
end
if ENV['ORACLE_ENHANCED_PATH']
gem 'activerecord-oracle_enhanced-adapter', :path => ENV['ORACLE_ENHANCED_PATH']
gem "activerecord-oracle_enhanced-adapter", :path => ENV['ORACLE_ENHANCED_PATH']
else
gem "activerecord-oracle_enhanced-adapter", :git => "git://github.com/rsim/oracle-enhanced.git"
end
Expand Down
19 changes: 10 additions & 9 deletions README.rdoc
@@ -1,7 +1,6 @@
== Welcome to Rails

Rails is a web-application framework that includes everything needed to create

database-backed web applications according to the {Model-View-Controller (MVC)}[http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller] pattern.

Understanding the MVC pattern is key to understanding Rails. MVC divides your application
Expand All @@ -21,14 +20,16 @@ can also be ordinary Ruby classes, or Ruby classes that implement a set of inter
provided by the ActiveModel module. You can read more about Active Record in its
{README}[link:files/activerecord/README_rdoc.html].

The controller and view are handled by the Action Pack, which handles both
layers by its two parts: Action View and Action Controller. These two layers
are bundled in a single package due to their heavy interdependence. This is
unlike the relationship between the Active Record and Action Pack that is much
more separate. Each of these packages can be used independently outside of
Rails. You can read more about Action Pack in its
{README}[link:files/actionpack/README_rdoc.html].
The Controller layer is responsible for handling incoming HTTP requests and providing a
suitable response. Usually this means returning HTML, but Rails controllers can also
generate XML, JSON, PDFs, mobile-specific views, and more. Controllers manipulate models
and render view templates in order to generate the appropriate HTTP response.

In Rails, the Controller and View layers are handled together by Action Pack.
These two layers are bundled in a single package due to their heavy interdependence.
This is unlike the relationship between the Active Record and Action Pack which are
independent. Each of these packages can be used independently outside of Rails. You
can read more about Action Pack in its {README}[link:files/actionpack/README_rdoc.html].

== Getting Started

Expand Down Expand Up @@ -64,7 +65,7 @@ Rails. You can read more about Action Pack in its
== Contributing

We encourage you to contribute to Ruby on Rails! Please check out the {Contributing to Rails
guide}[http://edgeguides.rubyonrails.org/contributing_to_rails.html] for guidelines about how
guide}[http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html] for guidelines about how
to proceed. {Join us}[http://contributors.rubyonrails.org]!

== License
Expand Down
8 changes: 4 additions & 4 deletions actionmailer/lib/action_mailer/base.rb
Expand Up @@ -58,7 +58,7 @@ module ActionMailer #:nodoc:
# will accept (any valid Email header including optional fields).
#
# The mail method, if not passed a block, will inspect your views and send all the views with
# the same name as the method, so the above action would send the +welcome.text.plain.erb+ view
# the same name as the method, so the above action would send the +welcome.text.erb+ view
# file as well as the +welcome.text.html.erb+ view file in a +multipart/alternative+ email.
#
# If you want to explicitly render only certain templates, pass a block:
Expand Down Expand Up @@ -89,7 +89,7 @@ module ActionMailer #:nodoc:
#
# To define a template to be used with a mailing, create an <tt>.erb</tt> file with the same
# name as the method in your mailer model. For example, in the mailer defined above, the template at
# <tt>app/views/notifier/signup_notification.text.plain.erb</tt> would be used to generate the email.
# <tt>app/views/notifier/welcome.text.erb</tt> would be used to generate the email.
#
# Variables defined in the model are accessible as instance variables in the view.
#
Expand Down Expand Up @@ -157,7 +157,7 @@ module ActionMailer #:nodoc:
# by the content type. Each such detected template will be added as separate part to the message.
#
# For example, if the following templates exist:
# * signup_notification.text.plain.erb
# * signup_notification.text.erb
# * signup_notification.text.html.erb
# * signup_notification.text.xml.builder
# * signup_notification.text.yaml.erb
Expand All @@ -182,7 +182,7 @@ module ActionMailer #:nodoc:
# end
# end
#
# Which will (if it had both a <tt>welcome.text.plain.erb</tt> and <tt>welcome.text.html.erb</tt>
# Which will (if it had both a <tt>welcome.text.erb</tt> and <tt>welcome.text.html.erb</tt>
# template in the view directory), send a complete <tt>multipart/mixed</tt> email with two parts,
# the first part being a <tt>multipart/alternative</tt> with the text and HTML email parts inside,
# and the second being a <tt>application/pdf</tt> with a Base64 encoded copy of the file.pdf book
Expand Down
1 change: 1 addition & 0 deletions actionpack/lib/action_controller/metal/redirecting.rb
Expand Up @@ -43,6 +43,7 @@ module Redirecting
#
# The status code can either be a standard {HTTP Status code}[http://www.iana.org/assignments/http-status-codes] as an
# integer, or a symbol representing the downcased, underscored and symbolized description.
# Note that the status code must be a 3xx HTTP code, or redirection will not occur.
#
# It is also possible to assign a flash message as part of the redirection. There are two special accessors for commonly used the flash names
# +alert+ and +notice+ as well as a general purpose +flash+ bucket.
Expand Down
12 changes: 11 additions & 1 deletion actionpack/lib/action_dispatch/http/upload.rb
Expand Up @@ -4,7 +4,7 @@ class UploadedFile
attr_accessor :original_filename, :content_type, :tempfile, :headers

def initialize(hash)
@original_filename = hash[:filename]
@original_filename = encode_filename(hash[:filename])
@content_type = hash[:type]
@headers = hash[:head]
@tempfile = hash[:tempfile]
Expand All @@ -30,6 +30,16 @@ def rewind
def size
@tempfile.size
end

private
def encode_filename(filename)
# Encode the filename in the utf8 encoding, unless it is nil or we're in 1.8
if "ruby".encoding_aware? && filename
filename.force_encoding("UTF-8").encode!
else
filename
end
end
end

module Upload
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -219,9 +219,9 @@ def convert_to_model(object)
# <% end %>
#
# If you have an object that needs to be represented as a different
# parameter, like a Client that acts as a Person:
# parameter, like a Person that acts as a Client:
#
# <%= form_for(@post, :as => :client) do |f| %>
# <%= form_for(@person, :as => :client) do |f| %>
# ...
# <% end %>
#
Expand Down Expand Up @@ -290,7 +290,7 @@ def convert_to_model(object)
#
# Example:
#
# <%= form(@post) do |f| %>
# <%= form_for(@post) do |f| %>
# <% f.fields_for(:comments, :include_id => false) do |cf| %>
# ...
# <% end %>
Expand Down
11 changes: 5 additions & 6 deletions actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -255,16 +255,15 @@ def word_wrap(text, *args)
# simple_format("<span>I'm allowed!</span> It's true.", {}, :sanitize => false)
# # => "<p><span>I'm allowed!</span> It's true.</p>"
def simple_format(text, html_options={}, options={})
text = text ? text.to_str : ''
text = text.dup if text.frozen?
text = '' if text.nil?
start_tag = tag('p', html_options, true)
text = sanitize(text) unless options[:sanitize] == false
text = text.to_str
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
text.insert 0, start_tag
text.concat("</p>")
text = sanitize(text) unless options[:sanitize] == false
text
text.html_safe.safe_concat("</p>")
end

# Creates a Cycle object whose _to_s_ method cycles through elements of an
Expand All @@ -281,7 +280,7 @@ def simple_format(text, html_options={}, options={})
# @items = [1,2,3,4]
# <table>
# <% @items.each do |item| %>
# <tr class="<%= cycle("even", "odd") -%>">
# <tr class="<%= cycle("odd", "even") -%>">
# <td>item</td>
# </tr>
# <% end %>
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/translation_helper.rb
Expand Up @@ -5,7 +5,7 @@ module I18n
class ExceptionHandler
include Module.new {
def call(exception, locale, key, options)
exception.is_a?(MissingTranslation) ? super.html_safe : super
exception.is_a?(MissingTranslation) && options[:rescue_format] == :html ? super.html_safe : super
end
}
end
Expand Down
17 changes: 13 additions & 4 deletions actionpack/lib/sprockets/railtie.rb
Expand Up @@ -30,7 +30,7 @@ def self.using_coffee?

ActiveSupport.on_load(:action_view) do
include ::Sprockets::Helpers::RailsHelper

app.assets.context_class.instance_eval do
include ::Sprockets::Helpers::RailsHelper
end
Expand All @@ -54,12 +54,21 @@ def asset_environment(app)
env = Sprockets::Environment.new(app.root.to_s)

env.static_root = File.join(app.root.join("public"), assets.prefix)
env.paths.concat assets.paths

if env.respond_to?(:append_path)
assets.paths.each { |path| env.append_path(path) }
else
env.paths.concat assets.paths
end

env.logger = Rails.logger

env.js_compressor = expand_js_compressor(assets.js_compressor)
env.css_compressor = expand_css_compressor(assets.css_compressor)
if assets.compress
# temporarily hardcode default JS compressor to uglify. Soon, it will work
# the same as SCSS, where a default plugin sets the default.
env.js_compressor = expand_js_compressor(assets.js_compressor || :uglifier)
env.css_compressor = expand_css_compressor(assets.css_compressor)
end

env
end
Expand Down
7 changes: 7 additions & 0 deletions actionpack/test/dispatch/uploaded_file_test.rb
Expand Up @@ -12,6 +12,13 @@ def test_original_filename
uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
assert_equal 'foo', uf.original_filename
end

if "ruby".encoding_aware?
def test_filename_should_be_in_utf_8
uf = Http::UploadedFile.new(:filename => 'foo', :tempfile => Object.new)
assert_equal "UTF-8", uf.original_filename.encoding.to_s
end
end

def test_content_type
uf = Http::UploadedFile.new(:type => 'foo', :tempfile => Object.new)
Expand Down
8 changes: 8 additions & 0 deletions actionpack/test/template/translation_helper_test.rb
Expand Up @@ -38,11 +38,19 @@ def test_delegates_localize_to_i18n
def test_returns_missing_translation_message_wrapped_into_span
expected = '<span class="translation_missing" title="translation missing: en.translations.missing">Missing</span>'
assert_equal expected, translate(:"translations.missing")
assert_equal true, translate(:"translations.missing").html_safe?
end

def test_returns_missing_translation_message_using_nil_as_rescue_format
expected = 'translation missing: en.translations.missing'
assert_equal expected, translate(:"translations.missing", :rescue_format => nil)
assert_equal false, translate(:"translations.missing", :rescue_format => nil).html_safe?
end

def test_i18n_translate_defaults_to_nil_rescue_format
expected = 'translation missing: en.translations.missing'
assert_equal expected, I18n.translate(:"translations.missing")
assert_equal false, I18n.translate(:"translations.missing").html_safe?
end

def test_translation_returning_an_array
Expand Down
12 changes: 4 additions & 8 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -428,10 +428,6 @@ class Base
class_attribute :default_scopes, :instance_writer => false
self.default_scopes = []

# Boolean flag to prevent infinite recursion when evaluating default scopes
class_attribute :apply_default_scope, :instance_writer => false
self.apply_default_scope = true

# Returns a hash of all the attributes that have been specified for serialization as
# keys and their class restriction as values.
class_attribute :serialized_attributes
Expand Down Expand Up @@ -1266,11 +1262,11 @@ def default_scope(scope = {})
self.default_scopes = default_scopes + [scope]
end

# The apply_default_scope flag is used to prevent an infinite recursion situation where
# The @ignore_default_scope flag is used to prevent an infinite recursion situation where
# a default scope references a scope which has a default scope which references a scope...
def build_default_scope #:nodoc:
return unless apply_default_scope
self.apply_default_scope = false
return if defined?(@ignore_default_scope) && @ignore_default_scope
@ignore_default_scope = true

if method(:default_scope).owner != Base.singleton_class
default_scope
Expand All @@ -1286,7 +1282,7 @@ def build_default_scope #:nodoc:
end
end
ensure
self.apply_default_scope = true
@ignore_default_scope = false
end

# Returns the class type of the record using the current module as a prefix. So descendants of
Expand Down
Expand Up @@ -119,6 +119,7 @@ def table_exists?(name)

with_connection do |conn|
conn.tables.each { |table| @tables[table] = true }
@tables[name] = true if !@tables.key?(name) && conn.table_exists?(name)
end

@tables.key? name
Expand Down
Expand Up @@ -386,13 +386,13 @@ def remove(*column_names)
# Removes the given index from the table.
#
# ===== Examples
# ====== Remove the suppliers_name_index in the suppliers table
# t.remove_index :name
# ====== Remove the index named accounts_branch_id_index in the accounts table
# ====== Remove the index_table_name_on_column in the table_name table
# t.remove_index :column
# ====== Remove the index named index_table_name_on_branch_id in the table_name table
# t.remove_index :column => :branch_id
# ====== Remove the index named accounts_branch_id_party_id_index in the accounts table
# ====== Remove the index named index_table_name_on_branch_id_and_party_id in the table_name table
# t.remove_index :column => [:branch_id, :party_id]
# ====== Remove the index named by_branch_party in the accounts table
# ====== Remove the index named by_branch_party in the table_name table
# t.remove_index :name => :by_branch_party
def remove_index(options = {})
@base.remove_index(@table_name, options)
Expand Down
Expand Up @@ -346,11 +346,11 @@ def add_index(table_name, column_name, options = {})

# Remove the given index from the table.
#
# Remove the suppliers_name_index in the suppliers table.
# remove_index :suppliers, :name
# Remove the index named accounts_branch_id_index in the accounts table.
# Remove the index_accounts_on_column in the accounts table.
# remove_index :accounts, :column
# Remove the index named index_accounts_on_branch_id in the accounts table.
# remove_index :accounts, :column => :branch_id
# Remove the index named accounts_branch_id_party_id_index in the accounts table.
# Remove the index named index_accounts_on_branch_id_and_party_id in the accounts table.
# remove_index :accounts, :column => [:branch_id, :party_id]
# Remove the index named by_branch_party in the accounts table.
# remove_index :accounts, :name => :by_branch_party
Expand Down
@@ -1,6 +1,6 @@
# encoding: utf-8

gem 'mysql2', '~> 0.3.0'
gem 'mysql2', '~> 0.3.6'
require 'mysql2'

module ActiveRecord
Expand Down
6 changes: 4 additions & 2 deletions activerecord/lib/active_record/migration.rb
Expand Up @@ -116,8 +116,10 @@ def initialize(name)
# with the name of the column. Other options include
# <tt>:name</tt> and <tt>:unique</tt> (e.g.
# <tt>{ :name => "users_name_index", :unique => true }</tt>).
# * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified
# by +index_name+.
# * <tt>remove_index(table_name, :column => column_name)</tt>: Removes the index
# specified by +column_name+.
# * <tt>remove_index(table_name, :name => index_name)</tt>: Removes the index
# specified by +index_name+.
#
# == Irreversible transformations
#
Expand Down
1 change: 1 addition & 0 deletions activerecord/test/support/config.rb
@@ -1,6 +1,7 @@
require 'yaml'
require 'erubis'
require 'fileutils'
require 'pathname'

module ARTest
class << self
Expand Down

0 comments on commit a223363

Please sign in to comment.