Permalink
Browse files

Fixed merge conflicts

  • Loading branch information...
karsthammer committed Aug 3, 2011
2 parents e954491 + 07bcdbf commit 82265496e6ceba374b49dc0002909d1f1578efea
View
@@ -1,3 +1,8 @@
# Version 1.2.2
* Fix a bug in params parsing
* Call .scoped only if it is available
# Version 1.2.1
* Fix a bug with namespaces
View
@@ -1,6 +1,6 @@
source "http://rubygems.org"
gem "rails", "3.0.3"
gem "rails", "3.1.0.rc4"
gem "responders", "~> 0.6.0"
gem "has_scope", "~> 0.5.0"
gem "mocha"
View
@@ -1,80 +1,96 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.6)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
actionmailer (3.1.0.rc4)
actionpack (= 3.1.0.rc4)
mail (~> 2.3.0)
actionpack (3.1.0.rc4)
activemodel (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.0)
rack-cache (~> 1.0.1)
rack-mount (~> 0.8.1)
rack-test (~> 0.6.0)
sprockets (~> 2.0.0.beta.10)
tzinfo (~> 0.3.27)
activemodel (3.1.0.rc4)
activesupport (= 3.1.0.rc4)
bcrypt-ruby (~> 2.1.4)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.0.rc4)
activemodel (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
arel (~> 2.1.1)
tzinfo (~> 0.3.27)
activeresource (3.1.0.rc4)
activemodel (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
activesupport (3.1.0.rc4)
multi_json (~> 1.0)
arel (2.1.1)
bcrypt-ruby (2.1.4)
builder (3.0.0)
erubis (2.7.0)
has_scope (0.5.0)
i18n (0.5.0)
mail (2.2.14)
activesupport (>= 2.3.6)
hike (1.1.0)
i18n (0.6.0)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mocha (0.9.8)
rake
multi_json (1.0.3)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (1.3.0)
rack-cache (1.0.2)
rack (>= 0.4)
rack-mount (0.8.1)
rack (>= 1.0.0)
rack-test (0.5.7)
rack-ssl (1.3.2)
rack
rack-test (0.6.0)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
rails (3.1.0.rc4)
actionmailer (= 3.1.0.rc4)
actionpack (= 3.1.0.rc4)
activerecord (= 3.1.0.rc4)
activeresource (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
railties (= 3.1.0.rc4)
railties (3.1.0.rc4)
actionpack (= 3.1.0.rc4)
activesupport (= 3.1.0.rc4)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
thor (~> 0.14.4)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.8.7)
responders (0.6.2)
test-unit (2.2.0)
rdoc (3.6.1)
responders (0.6.4)
sprockets (2.0.0.beta.10)
hike (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
test-unit (2.3.0)
thor (0.14.6)
tilt (1.3.2)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
tzinfo (0.3.28)
PLATFORMS
ruby
DEPENDENCIES
has_scope (~> 0.5.0)
mocha
rails (= 3.0.3)
rails (= 3.1.0.rc4)
responders (~> 0.6.0)
test-unit
View
@@ -8,32 +8,30 @@ Plus, making your controllers follow a pattern, it helps you to write better
code by following fat models and skinny controllers convention. There are
two screencasts available besides this README:
http://railscasts.com/episodes/230-inherited-resources
http://akitaonrails.com/2009/09/01/screencast-real-thin-restful-controllers-with-inherited-resources
* http://railscasts.com/episodes/230-inherited-resources
* http://akitaonrails.com/2009/09/01/screencast-real-thin-restful-controllers-with-inherited-resources
== Installation
=== Rails 3
Inherited Resources master branch is now supports Rails 3 and is NOT backward compatible.
You can let bundler install Inherited Resources by adding this line to your application's Gemfile:
You can let bundler to install Inherited Resources by adding this line to your application's Gemfile:
gem 'inherited_resources', '~> 1.2.1'
gem 'inherited_resources'
And then execute:
bundle install
Or install it yourself as:
gem install inherited_resources --version=1.2.1
gem install inherited_resources
=== Rails 2.3.x
If you want to use the Rails 2.3.x version, you should install:
sudo gem install inherited_resources --version=1.0.6
gem install inherited_resources --version=1.0.6
Or checkout from the v1.0 branch:
@@ -516,6 +514,8 @@ check this Wiki page:
https://github.com/josevalim/inherited_resources/wiki/Views-Inheritance
Notice that Rails 3.1 ships with view inheritance built-in.
== Some DSL
For those DSL lovers, InheritedResources won't leave you alone. You can overwrite
@@ -536,9 +536,9 @@ And then you can rewrite the last example as:
== Bugs and Feedback
If you discover any bugs or want to drop a line, join us in the mailing list:
If you discover any bugs, please describe it in the issues tracker, including Rails and Inherited Resources versions.
http://groups.google.com/group/inherited_resources
Questions are better handled on StackOverflow.
Copyright (c) 2009 José Valim http://blog.plataformatec.com.br
Copyright (c) 2011 José Valim http://blog.plataformatec.com.br
See the attached MIT License.
@@ -1,6 +1,3 @@
require 'inherited_resources/blank_slate'
require 'inherited_resources/responder'
module InheritedResources
# = Base
#
@@ -21,7 +18,7 @@ def self.inherit_resources(base)
extend InheritedResources::UrlHelpers
# Add at least :html mime type
respond_to :html
respond_to :html if self.mimes_for_respond_to.empty?
self.responder = InheritedResources::Responder
helper_method :resource, :collection, :resource_class, :association_chain,
@@ -33,7 +30,8 @@ def self.inherit_resources(base)
:parent_url, :parent_path,
:smart_resource_url, :smart_collection_url
self.class_attribute :resource_class, :parents_symbols, :resources_configuration, :instance_writer => false
self.class_attribute :resource_class unless self.respond_to? :resource_class
self.class_attribute :parents_symbols, :resources_configuration, :instance_writer => false
protected :resource_class, :parents_symbols, :resources_configuration,
:resource_class?, :parents_symbols?, :resources_configuration?
@@ -42,4 +40,4 @@ def self.inherit_resources(base)
inherit_resources(self)
end
end
end
@@ -1,10 +1,12 @@
require 'rails/engine'
require 'responders'
require 'inherited_resources/blank_slate'
require 'inherited_resources/responder'
module InheritedResources
ACTIONS = [ :index, :show, :new, :edit, :create, :update, :destroy ] unless self.const_defined?(:ACTIONS)
autoload :Actions, 'inherited_resources/actions'
autoload :Base, 'inherited_resources/base'
autoload :BaseHelpers, 'inherited_resources/base_helpers'
autoload :ShallowHelpers, 'inherited_resources/shallow_helpers'
autoload :BelongsToHelpers, 'inherited_resources/belongs_to_helpers'
@@ -20,7 +22,7 @@ def self.flash_keys=(array)
Responders::FlashResponder.flash_keys = array
end
class Railtie < ::Rails::Railtie
class Railtie < ::Rails::Engine
config.inherited_resources = InheritedResources
if config.respond_to?(:app_generators)
config.app_generators.scaffold_controller = :inherited_resources_controller
@@ -49,7 +49,7 @@ def resource
# instance variable.
#
def build_resource
get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_build, resource_params))
get_resource_ivar || set_resource_ivar(end_of_association_chain.send(method_for_build, *resource_params))
end
# Responsible for saving the resource on :create method. Overwriting this
@@ -75,7 +75,7 @@ def create_resource(object)
# end
#
def update_resource(object, attributes)
object.update_attributes(attributes)
object.update_attributes(*attributes)
end
# Handle the :destroy method for the resource. Overwrite it to call your
@@ -300,7 +300,19 @@ def smart_collection_url
# extract attributes from params
def resource_params
params[resource_request_name] || params[resource_instance_name] || {}
rparams = [params[resource_request_name] || params[resource_instance_name] || {}]
rparams << as_role if role_given?
rparams
end
# checking if role given
def role_given?
self.resources_configuration[:self][:role].present?
end
# getting role for mass-asignment
def as_role
{ :as => self.resources_configuration[:self][:role] }
end
end
end
@@ -255,6 +255,12 @@ def custom_actions(options)
end
end
# Defines the role to use when creating or updating resource.
# Makes sense when using rails 3.1 mass assignment conventions
def with_role(role)
self.resources_configuration[:self][:role] = role.try(:to_sym)
end
private
def acts_as_singleton! #:nodoc:
@@ -279,15 +285,24 @@ def acts_as_shallow! #:nodoc:
# Initialize resources class accessors and set their default values.
#
def initialize_resources_class_accessors! #:nodoc:
# First priority is the namespaced modek, e.g. User::Group
self.resource_class = begin
# First priority is the namespaced model, e.g. User::Group
self.resource_class ||= begin
namespaced_class = self.name.sub(/Controller/, '').singularize
namespaced_class.constantize
rescue NameError
nil
end
# Second priority the camelcased c, i.e. UserGroup
# Second priority is the top namespace model, e.g. EngineName::Article for EngineName::Admin::ArticlesController
self.resource_class ||= begin
namespaced_classes = self.name.sub(/Controller/, '').split('::')
namespaced_class = [namespaced_classes.first, namespaced_classes.last].join('::').singularize
namespaced_class.constantize
rescue NameError
nil
end
# Third priority the camelcased c, i.e. UserGroup
self.resource_class ||= begin
camelcased_class = self.name.sub(/Controller/, '').gsub('::', '').singularize
camelcased_class.constantize
@@ -1,3 +1,3 @@
module InheritedResources
VERSION = '1.2.1'.freeze
VERSION = '1.2.2'.freeze
end
View
@@ -126,7 +126,16 @@ def test_block_is_called_when_student_is_destroyed
def test_options_are_used_in_respond_with
@request.accept = "application/xml"
Student.stubs(:new).returns(mock_student(:save => true, :to_xml => "XML"))
mock_student = mock_student(:save => true, :to_xml => "XML")
Student.stubs(:new).returns(mock_student)
# Bug in mocha does not accept strings on respond_to
mock_student.singleton_class.class_eval do
def respond_to?(method, *)
method == "to_xml" || super
end
end
post :create
assert_equal "http://test.host/", @response.location
end
Oops, something went wrong.

0 comments on commit 8226549

Please sign in to comment.