rosa-build/lib/plugins/related_models/url_helpers.rb

30 lines
825 B
Ruby
Raw Normal View History

2012-01-30 20:39:34 +00:00
# -*- encoding : utf-8 -*-
2011-11-30 12:58:14 +00:00
module RelatedModels
module UrlHelpers
protected
def create_resources_url_helpers!
segment = if parents_symbols.include? :polymorphic
:polymorphic
else
resources_configuration[symbols_for_association_chain.first][:route_name]
end
unless parent.nil?
class_eval <<-URL_HELPERS, __FILE__, __LINE__
protected
def parent_path(*given_args)
given_options = given_args.extract_options!
#{segment}_path(parent, given_options)
end
def parent_url(*given_args)
given_options = given_args.extract_options!
#{segment}_url(parent, given_options)
end
URL_HELPERS
end
end
end
end