From 8dca6586ded76d5950b4fccfb720e2861efede6d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 30 Nov 2006 21:45:31 +0000 Subject: Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5652 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/form_helper.rb | 9 +++++++++ actionpack/lib/action_view/helpers/form_tag_helper.rb | 5 +++++ actionpack/test/template/form_helper_test.rb | 6 ++++++ railties/CHANGELOG | 2 ++ railties/lib/commands/servers/lighttpd.rb | 8 ++++---- railties/lib/commands/servers/mongrel.rb | 5 ++++- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 8aa0b42fe1..8d89f74c3b 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -223,6 +223,11 @@ module ActionView def radio_button(object_name, method, tag_value, options = {}) InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_radio_button_tag(tag_value, options) end + + + def label(object_name, method, options = {}) + InstanceTag.new(object_name, method, self, nil, options.delete(:object)).to_label_tag(options) + end end class InstanceTag #:nodoc: @@ -328,6 +333,10 @@ module ActionView tag_text << ">True" end + def to_label_tag(options = {}) + label_tag(options.delete(:text) || value(object).humanize, options.reverse_merge(:for => tag_id)) + end + def to_content_tag(tag_name, options = {}) content_tag(tag_name, value(object), options) end diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index e2e796e7c8..661034e5ca 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -153,6 +153,11 @@ module ActionView tag :input, html_options end + # Creates a label tag. + def label_tag(text, options = {}) + content_tag :label, text, options + end + # Creates a submit button with the text value as the caption. If options contains a pair with the key of "disable_with", # then the value will be used to rename a disabled version of the submit button. def submit_tag(value = "Save changes", options = {}) diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index a7ceb6b30f..f7d51b2f2d 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -163,6 +163,12 @@ class FormHelperTest < Test::Unit::TestCase ) end + def test_label + assert_dom_equal('', label("post", "body")) + assert_dom_equal('', label("post", "body", :text => "Super body")) + assert_dom_equal('', label("post", "body", :text => "Super body", :class => "strong")) + end + def test_explicit_name assert_dom_equal( '', text_field("post", "title", "name" => "dont guess") diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 2246ab9e6a..b183d13d7a 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fixed that script/server running against Mongrel should tail the proper log regardless of the environment [DHH] + * Update initializer to load Rails::VERSION as soon as possible. Closes #6698. [Nicholas Seckar] * Added ActiveRecord::Base.clear_active_connections! in development mode so the database connection is not carried over from request to request. Some databases won't reread the schema if that doesn't happen (I'm looking at you SQLite), so you have to restart the server after each migration (= no fun) [DHH] diff --git a/railties/lib/commands/servers/lighttpd.rb b/railties/lib/commands/servers/lighttpd.rb index 07d4f9d0bf..83a2c8a8e0 100644 --- a/railties/lib/commands/servers/lighttpd.rb +++ b/railties/lib/commands/servers/lighttpd.rb @@ -11,10 +11,6 @@ unless defined?(FCGI) exit 1 end -require 'initializer' -configuration = Rails::Initializer.run(:initialize_logger).configuration -default_config_file = config_file = Pathname.new("#{RAILS_ROOT}/config/lighttpd.conf").cleanpath - require 'optparse' detach = false @@ -67,6 +63,10 @@ puts "=> Rails application starting on http://#{ip || default_ip}:#{port || defa tail_thread = nil if !detach + require 'initializer' + configuration = Rails::Initializer.run(:initialize_logger).configuration + default_config_file = config_file = Pathname.new("#{RAILS_ROOT}/config/lighttpd.conf").cleanpath + puts "=> Call with -d to detach" puts "=> Ctrl-C to shutdown server (see config/lighttpd.conf for options)" detach = false diff --git a/railties/lib/commands/servers/mongrel.rb b/railties/lib/commands/servers/mongrel.rb index e5bde9fe1b..63dd6bd71c 100644 --- a/railties/lib/commands/servers/mongrel.rb +++ b/railties/lib/commands/servers/mongrel.rb @@ -33,8 +33,11 @@ end puts "=> Rails application starting on http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}" if OPTIONS[:detach] - `mongrel_rails start -d -p #{OPTIONS[:port]} -a #{OPTIONS[:ip]} -e #{OPTIONS[:environment]}` + `mongrel_rails start -d -p #{OPTIONS[:port]} -a #{OPTIONS[:ip]} -e #{OPTIONS[:environment]} -P #{RAILS_ROOT}/tmp/pids/mongrel.pid` else + ENV["RAILS_ENV"] = OPTIONS[:environment] + RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) + require 'initializer' Rails::Initializer.run(:initialize_logger) -- cgit v1.2.3