Skip to content

Commit

Permalink
resolves rdoc conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn committed Sep 23, 2010
2 parents afdf86e + 5965219 commit 8c0c815
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 68 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -93,9 +93,9 @@ module ActionController
# * ActiveRecord::SessionStore - Sessions are stored in your database, which works better than PStore with multiple app servers and,
# unlike CookieStore, hides your session contents from the user. To use ActiveRecord::SessionStore, set
#
# config.action_controller.session_store = :active_record_store
# MyApplication::Application.config.session_store :active_record_store
#
# in your <tt>config/environment.rb</tt> and run <tt>rake db:sessions:create</tt>.
# in your <tt>config/initializers/session_store.rb</tt> and run <tt>script/rails g session_migration</tt>.
#
# == Responses
#
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/base.rb
Expand Up @@ -153,7 +153,7 @@ module ActionView #:nodoc:
#
# This refreshes the sidebar, removes a person element and highlights the user list.
#
# See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
# See the ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods documentation for more details.
class Base
module Subclasses
end
Expand Down
10 changes: 6 additions & 4 deletions actionpack/lib/action_view/helpers/form_helper.rb
Expand Up @@ -211,7 +211,7 @@ module FormHelper
# If you have an object that needs to be represented as a different
# parameter, like a Client that acts as a Person:
#
# <%= form_for(@post, :as => :client do |f| %>
# <%= form_for(@post, :as => :client) do |f| %>
# ...
# <% end %>
#
Expand All @@ -228,8 +228,8 @@ module FormHelper
# ...
# <% end %>
#
# Where +@document = Document.find(params[:id])+ and
# +@comment = Comment.new+.
# Where <tt>@document = Document.find(params[:id])</tt> and
# <tt>@comment = Comment.new</tt>.
#
# === Unobtrusive JavaScript
#
Expand Down Expand Up @@ -656,11 +656,13 @@ def hidden_field(object_name, method, options = {})
InstanceTag.new(object_name, method, self, options.delete(:object)).to_input_field_tag("hidden", options)
end

# Returns an file upload input tag tailored for accessing a specified attribute (identified by +method+) on an object
# Returns a file upload input tag tailored for accessing a specified attribute (identified by +method+) on an object
# assigned to the template (identified by +object+). Additional options on the input tag can be passed as a
# hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example
# shown.
#
# Using this method inside a +form_for+ block will set the enclosing form's encoding to <tt>multipart/form-data</tt>.
#
# ==== Examples
# file_field(:user, :avatar)
# # => <input type="file" id="user_avatar" name="user[avatar]" />
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/javascript_helper.rb
Expand Up @@ -65,7 +65,7 @@ def escape_javascript(javascript)
# //]]>
# </script>
#
# +html_options+ may be a hash of attributes for the <tt><script></tt>
# +html_options+ may be a hash of attributes for the <tt>\<script></tt>
# tag. Example:
# javascript_tag "alert('All is good')", :defer => 'defer'
# # => <script defer="defer" type="text/javascript">alert('All is good')</script>
Expand Down
8 changes: 4 additions & 4 deletions actionpack/lib/action_view/helpers/prototype_helper.rb
Expand Up @@ -161,7 +161,7 @@ def include_helpers_from_context

# JavaScriptGenerator generates blocks of JavaScript code that allow you
# to change the content and presentation of multiple DOM elements. Use
# this in your Ajax response bodies, either in a <tt><script></tt> tag
# this in your Ajax response bodies, either in a <tt>\<script></tt> tag
# or as plain JavaScript sent with a Content-type of "text/javascript".
#
# Create new instances with PrototypeHelper#update_page or with
Expand Down Expand Up @@ -224,7 +224,7 @@ def include_helpers_from_context
#
# You can also use PrototypeHelper#update_page_tag instead of
# PrototypeHelper#update_page to wrap the generated JavaScript in a
# <tt><script></tt> tag.
# <tt>\<script></tt> tag.
module GeneratorMethods
def to_s #:nodoc:
(@lines * $/).tap do |javascript|
Expand Down Expand Up @@ -583,10 +583,10 @@ def update_page(&block)
end

# Works like update_page but wraps the generated JavaScript in a
# <tt><script></tt> tag. Use this to include generated JavaScript in an
# <tt>\<script></tt> tag. Use this to include generated JavaScript in an
# ERb template. See JavaScriptGenerator for more information.
#
# +html_options+ may be a hash of <tt><script></tt> attributes to be
# +html_options+ may be a hash of <tt>\<script></tt> attributes to be
# passed to ActionView::Helpers::JavaScriptHelper#javascript_tag.
def update_page_tag(html_options = {}, &block)
javascript_tag update_page(&block), html_options
Expand Down
4 changes: 2 additions & 2 deletions activemodel/lib/active_model/validator.rb
Expand Up @@ -7,7 +7,7 @@ module ActiveModel #:nodoc:
# == Active Model Validator
#
# A simple base class that can be used along with
# +ActiveModel::Validations::ClassMethods.validates_with+
# ActiveModel::Validations::ClassMethods.validates_with
#
# class Person
# include ActiveModel::Validations
Expand Down Expand Up @@ -42,7 +42,7 @@ module ActiveModel #:nodoc:
# end
# end
#
# To cause a validation error, you must add to the <tt>record<tt>'s errors directly
# To cause a validation error, you must add to the <tt>record</tt>'s errors directly
# from within the validators message
#
# class MyValidator < ActiveModel::Validator
Expand Down
2 changes: 1 addition & 1 deletion activeresource/test/cases/base/schema_test.rb
Expand Up @@ -386,7 +386,7 @@ def teardown
assert_not_equal matz.known_attributes, rick.known_attributes, "should have had different known attributes too"
end

test "setting schema then fetching should add schema attributes to the intance attributes" do
test "setting schema then fetching should add schema attributes to the instance attributes" do
# an attribute in common with fetched instance and one that isn't
new_schema = {'age' => 'integer', 'name' => 'string',
'height' => 'float', 'bio' => 'text',
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/action_controller_overview.textile
Expand Up @@ -161,7 +161,7 @@ If you need a different session storage mechanism, you can change it in the +con
<ruby>
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
# (create the session table with "script/rails g session_migration")
# YourApp::Application.config.session_store :active_record_store
</ruby>

Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/action_view_overview.textile
Expand Up @@ -654,7 +654,7 @@ The core method of this helper, form_for, gives you the ability to create a form

<ruby>
# Note: a @person variable will have been created in the controller (e.g. @person = Person.new)
<%= form_for :person, @person, :url => { :action => "create" } do |f| %>
<%= form_for @person, :url => { :action => "create" } do |f| %>
<%= f.text_field :first_name %>
<%= f.text_field :last_name %>
<%= submit_tag 'Create' %>
Expand Down
2 changes: 1 addition & 1 deletion railties/guides/source/caching_with_rails.textile
Expand Up @@ -367,7 +367,7 @@ h3. Advanced Caching
Along with the built-in mechanisms outlined above, a number of excellent plugins exist to help with finer grained control over caching. These include Chris Wanstrath's excellent cache_fu plugin (more info "here":http://errtheblog.com/posts/57-kickin-ass-w-cachefu ) and Evan Weaver's interlock plugin (more info "here":http://blog.evanweaver.com/articles/2007/12/13/better-rails-caching/ ). Both of these plugins play nice with memcached and are a must-see for anyone
seriously considering optimizing their caching needs.

Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool.
Also the new "Cache money":http://github.com/ngmoco/cache-money/tree/rails3 plugin is supposed to be mad cool.

h3. References

Expand Down
2 changes: 0 additions & 2 deletions railties/guides/source/configuring.textile
Expand Up @@ -149,8 +149,6 @@ WARNING: Threadsafe operation is incompatible with the normal workings of develo

* +config.action_controller.optimise_named_routes+ turns on some optimizations in generating the routing table. It is set to +true+ by default.

* +config.action_controller.use_accept_header+ sets the rules for determining the response format. 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 there is no +format+ parameter, then the response format will be either HTML or Javascript depending on whether the request is an AJAX request.

* +config.action_controller.allow_forgery_protection+ enables or disables CSRF protection. By default this is +false+ in test mode and +true+ in all other modes.

* +config.action_controller.relative_url_root+ can be used to tell Rails that you are deploying to a subdirectory. The default is +ENV['RAILS_RELATIVE_URL_ROOT']+.
Expand Down
8 changes: 5 additions & 3 deletions railties/guides/source/form_helpers.textile
Expand Up @@ -222,7 +222,7 @@ end
The corresponding view +app/views/articles/new.html.erb+ using +form_for+ looks like this:

<erb>
<%= form_for :article, @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
<%= form_for @article, :url => { :action => "create" }, :html => {:class => "nifty_form"} do |f| %>
<%= f.text_field :title %>
<%= f.text_area :body, :size => "60x12" %>
<%= submit_tag "Create" %>
Expand Down Expand Up @@ -253,7 +253,7 @@ The helper methods called on the form builder are identical to the model object
You can create a similar binding without actually creating +&lt;form&gt;+ tags with the +fields_for+ helper. This is useful for editing additional model objects with the same form. For example if you had a Person model with an associated ContactDetail model you could create a form for creating both like so:

<erb>
<%= form_for :person, @person, :url => { :action => "create" } do |person_form| %>
<%= form_for @person, :url => { :action => "create" } do |person_form| %>
<%= person_form.text_field :name %>
<%= fields_for @person.contact_detail do |contact_details_form| %>
<%= contact_details_form.text_field :phone_number %>
Expand Down Expand Up @@ -549,7 +549,7 @@ will produce the same output if the current year is 2009 and the value chosen by

h3. Uploading Files

A common task is uploading some sort of file, whether it's a picture of a person or a CSV file containing data to process. The most important thing to remember with file uploads is that the form's encoding *MUST* be set to "multipart/form-data". If you're using +form_for+ just using +file_field+ inside of it does the trick, but if you're using +form_tag+ +:multi_part => true+ must passed as an HTML option, in the second options hash. If you forget to do this the file will not be uploaded.
A common task is uploading some sort of file, whether it's a picture of a person or a CSV file containing data to process. The most important thing to remember with file uploads is that the rendered form's encoding *MUST* be set to "multipart/form-data". If you use +form_for+, this is done automatically. If you use +form_tag+, you must set it yourself, as per the following example.

The following two forms both upload a file.

Expand All @@ -563,6 +563,8 @@ The following two forms both upload a file.
<% end %>
</erb>

NOTE: Since Rails 3.1, forms rendered using +form_for+ have their encoding set to <tt>multipart/form-data</tt> automatically once a +file_field+ is used inside the block. Previous versions required you to set this explicitly.

Rails provides the usual pair of helpers: the barebones +file_field_tag+ and the model oriented +file_field+. The only difference with other helpers is that you cannot set a default value for file inputs as this would have no meaning. As you would expect in the first case the uploaded file is in +params[:picture]+ and in the second case in +params[:person][:picture]+.

h4. What Gets Uploaded
Expand Down
82 changes: 43 additions & 39 deletions railties/guides/source/plugins.textile
Expand Up @@ -39,6 +39,7 @@ The examples in this guide require that you have a working rails application. T
gem install rails
rails new yaffle_guide
cd yaffle_guide
bundle install
rails generate scaffold bird name:string
rake db:migrate
rails server
Expand All @@ -51,44 +52,47 @@ NOTE: The aforementioned instructions will work for sqlite3. For more detailed

h4. Generate the Plugin Skeleton

Rails ships with a plugin generator which creates a basic plugin skeleton. Pass the plugin name, either 'CamelCased' or 'under_scored', as an argument. Pass +--with-generator+ to add an example generator also.
Rails ships with a plugin generator which creates a basic plugin skeleton. Pass the plugin name, either 'CamelCased' or 'under_scored', as an argument. Pass +--generator+ to add an example generator also.

This creates a plugin in +vendor/plugins+ including an +init.rb+ and +README+ as well as standard +lib+, +task+, and +test+ directories.

Examples:
<shell>
rails generate plugin yaffle
rails generate plugin yaffle --with-generator
rails generate plugin yaffle --generator
</shell>

To get more detailed help on the plugin generator, type +rails generate plugin+.

Later on this guide will describe how to work with generators, so go ahead and generate your plugin with the +--with-generator+ option now:
Later on this guide will describe how to work with generators, so go ahead and generate your plugin with the +--generator+ option now:

<shell>
rails generate plugin yaffle --with-generator
rails generate plugin yaffle --generator
</shell>

You should see the following output:

<shell>
create vendor/plugins/yaffle/lib
create vendor/plugins/yaffle/tasks
create vendor/plugins/yaffle/test
create vendor/plugins/yaffle/README
create vendor/plugins/yaffle/MIT-LICENSE
create vendor/plugins/yaffle/Rakefile
create vendor/plugins/yaffle
create vendor/plugins/yaffle/init.rb
create vendor/plugins/yaffle/install.rb
create vendor/plugins/yaffle/MIT-LICENSE
create vendor/plugins/yaffle/Rakefile
create vendor/plugins/yaffle/README
create vendor/plugins/yaffle/uninstall.rb
create vendor/plugins/yaffle/lib
create vendor/plugins/yaffle/lib/yaffle.rb
create vendor/plugins/yaffle/tasks/yaffle_tasks.rake
create vendor/plugins/yaffle/test/core_ext_test.rb
create vendor/plugins/yaffle/generators
create vendor/plugins/yaffle/generators/yaffle
create vendor/plugins/yaffle/generators/yaffle/templates
create vendor/plugins/yaffle/generators/yaffle/yaffle_generator.rb
create vendor/plugins/yaffle/generators/yaffle/USAGE
invoke generator
inside vendor/plugins/yaffle
create lib/generators
create lib/generators/yaffle_generator.rb
create lib/generators/USAGE
create lib/generators/templates
invoke test_unit
inside vendor/plugins/yaffle
create test
create test/yaffle_test.rb
create test/test_helper.rb
</shell>

h4. Organize Your Files
Expand All @@ -99,9 +103,7 @@ To make it easy to organize your files and to make the plugin more compatible wi
|-- lib
| |-- yaffle
| `-- yaffle.rb
`-- rails
|
`-- init.rb
`-- init.rb
</shell>

<ruby>
Expand All @@ -126,26 +128,26 @@ h4. Test Setup
# vendor/plugins/yaffle/test/database.yml

sqlite:
:adapter: sqlite
:dbfile: vendor/plugins/yaffle/test/yaffle_plugin.sqlite.db
adapter: sqlite
database: vendor/plugins/yaffle/test/yaffle_plugin.sqlite.db

sqlite3:
:adapter: sqlite3
:dbfile: vendor/plugins/yaffle/test/yaffle_plugin.sqlite3.db
adapter: sqlite3
database: vendor/plugins/yaffle/test/yaffle_plugin.sqlite3.db

postgresql:
:adapter: postgresql
:username: postgres
:password: postgres
:database: yaffle_plugin_test
:min_messages: ERROR
adapter: postgresql
username: postgres
password: postgres
database: yaffle_plugin_test
min_messages: ERROR

mysql:
:adapter: mysql
:host: localhost
:username: root
:password: password
:database: yaffle_plugin_test
adapter: mysql
host: localhost
username: root
password: password
database: yaffle_plugin_test
</yaml>

For this guide you'll need 2 tables/models, Hickwalls and Wickwalls, so add the following:
Expand Down Expand Up @@ -205,7 +207,7 @@ def load_schema

ActiveRecord::Base.establish_connection(config[db_adapter])
load(File.dirname(__FILE__) + "/schema.rb")
require File.dirname(__FILE__) + '/../rails/init'
require File.dirname(__FILE__) + '/../init'
end
</ruby>

Expand All @@ -218,9 +220,9 @@ Once you have these files in place, you can write your first test to ensure that
<ruby>
# vendor/plugins/yaffle/test/yaffle_test.rb

require File.dirname(__FILE__) + '/test_helper'
require 'test_helper'

class YaffleTest < Test::Unit::TestCase
class YaffleTest < ActiveSupport::TestCase
load_schema

class Hickwall < ActiveRecord::Base
Expand Down Expand Up @@ -252,16 +254,18 @@ You should see output like:
-> 0.0220s
-- create_table(:wickwalls, {:force=>true})
-> 0.0077s
-- create_table(:woodpeckers, {:force=>true})
-> 0.0069s
-- initialize_schema_migrations_table()
-> 0.0007s
-- assume_migrated_upto_version(0)
-- assume_migrated_upto_version(0, "db/migrate")
-> 0.0007s
Loaded suite /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader
Started
.
Finished in 0.002236 seconds.

1 test, 1 assertion, 0 failures, 0 errors
1 test, 2 assertion, 0 failures, 0 errors, 0 skips
</shell>

By default the setup above runs your tests with sqlite or sqlite3. To run tests with one of the other connection strings specified in +database.yml+, pass the DB environment variable to rake:
Expand Down

0 comments on commit 8c0c815

Please sign in to comment.