init.rb
# Settings more likely to need to be changed I've put nearer the top.
#
# At some point it would be good to define a full dsl, but I've got other
# things to do...
#
# These methods can be redefined in the block passed to the
# +automatic_resources+ method:
#
# automatic_resources :collection, :category, :item do
#   def finder_method_on_resource(resource)
#     case resource
#     when 'item'
#       'find'
#     else
#       'find_by_param!'
#     end
#   end
# end
#
Settings more likely to need to be changed I've put nearer the top.
At some point it would be good to define a full dsl, but I've got other
things to do

These methods can be redefined in the block passed to the
+automatic_resources+ method.


Settings more likely to need to be changed I ' ve put nearer the top . At some point it would be good to define a full dsl but I ' ve got other things to do These methods can be redefined in the block passed to the + automatic_resources + method .
def generate_url(formatted, prefix, name, suffix, resource, item, extra_args)
    index = active_resources.index(resource)
    raise "A route was called for #{ resource }, but #{ resource } is not currently active." unless index
    parts = active_resources[0...index]
    parts = parts.map { |r| self.class.route_part_for_resource(r) }
    method = [formatted, prefix, parts, name, suffix].flatten.compact.join('_')
    args = active_resources[0...index].map do |r| 
      send(self.class.finder_method_name_for_resource(r))
    end
    args.push item if item
    args = args + extra_args unless extra_args.blank?
    send(method, *args)
  end
def generate_url ( formatted , prefix , name , suffix , resource , item , extra_args ) index = active_resources . index ( resource ) raise "A route was called for #{ resource }, but #{ resource } is not currently active." unless index parts = active_resources [ 0 ... index ] parts = parts . map { | r | self . class . route_part_for_resource ( r ) } method = [ formatted , prefix , parts , name , suffix ] . flatten . compact . join ( '_' ) args = active_resources [ 0 ... index ] . map do | r | send ( self . class . finder_method_name_for_resource ( r ) ) end args . push item if item args = args + extra_args unless extra_args . blank? send ( method , * args ) end
Settings more likely to need to be changed I've put nearer the top.
Settings more likely to need to be changed I ' ve put nearer the top .
formatted
<not_specific>
prefix
<not_specific>
name
<not_specific>
suffix
<not_specific>
resource
<not_specific>
item
<not_specific>
extra_args
<not_specific>