Forked from pjg/resource_hacks lib for Rails 2.3.4
Created
February 13, 2010 22:59
-
-
Save markauskas/303715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionController | |
module Resources | |
class Resource | |
# Redefining methods from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/resources.rb so that the RESTful routes accept member_path option | |
def member_path | |
@member_path || options[:member_path] || "#{shallow_path_prefix}/#{path_segment}/:id" | |
end | |
def nesting_path_prefix | |
@nesting_path_prefix || options[:member_path] || "#{shallow_path_prefix}/#{path_segment}/:#{singular}_id" | |
end | |
def requirements(with_id = false) | |
@requirements ||= @options[:requirements] || {} | |
@id_requirement ||= options[:member_path].blank? ? { :id => @requirements.delete(:id) || /[^#{Routing::SEPARATORS.join}]+/ } : options[:member_path_requirements] || {} | |
with_id ? @requirements.merge(@id_requirement) : @requirements | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment