module AuthorizedRailsScaffolds::Macros::RouteExampleMacros
Public Instance Methods
example_index_path()
click to toggle source
Example index route: i.e. /awesome/users/2/foo_bars
# File lib/authorized_rails_scaffolds/macros/route_example_macros.rb, line 4 def example_index_path unless @example_index_path example_index_path_parts = [] parent_model_names.each do |parent_model| # users, 2 parent_value = example_parent_values["#{parent_model}_id"] example_index_path_parts << parent_model.pluralize example_index_path_parts << parent_value end # Example index route: i.e. /awesome/users/2/foo_bars @example_index_path = [parent_module_groups + example_index_path_parts + [resource_array_name]].join("/") end "/#{@example_index_path}" end
example_index_path_extra_params()
click to toggle source
Extra params for an example controller path: i.e. ‘, :user_id => 2’
# File lib/authorized_rails_scaffolds/macros/route_example_macros.rb, line 40 def example_index_path_extra_params @example_index_path_extra_params ||= example_parent_values.map{ |parent_model_id, parent_value| ", :#{parent_model_id} => \"#{parent_value}\"" }.join('') end
example_route_extra_params(use_shallow_route=false)
click to toggle source
# File lib/authorized_rails_scaffolds/macros/route_example_macros.rb, line 48 def example_route_extra_params(use_shallow_route=false) @example_route_extra_params ||= parent_model_names.collect{ |parent_table| ":#{parent_table}_id => #{references_test_name(parent_table)}.to_param" } use_shallow_route ? @example_route_extra_params[0..-2] : @example_route_extra_params end
example_show_path()
click to toggle source
# File lib/authorized_rails_scaffolds/macros/route_example_macros.rb, line 21 def example_show_path unless @example_show_path example_show_path_parts = [] parent_names = shallow_routes? ? parent_model_names[0..-2] : parent_model_names parent_names.each do |parent_model| # users, 2 parent_value = example_parent_values["#{parent_model}_id"] example_show_path_parts << parent_model.pluralize example_show_path_parts << parent_value end # Example index route: i.e. /awesome/users/2/foo_bars @example_show_path = [parent_module_groups + example_show_path_parts + [resource_array_name]].join("/") end "/#{@example_show_path}/1" end
example_show_path_extra_params()
click to toggle source
# File lib/authorized_rails_scaffolds/macros/route_example_macros.rb, line 44 def example_show_path_extra_params @example_show_path_extra_params ||= example_parent_values(shallow_routes?).map{ |parent_model_id, parent_value| ", :#{parent_model_id} => \"#{parent_value}\"" }.join('') end
Protected Instance Methods
example_parent_values(use_shallow_route=false)
click to toggle source
Creates example values for parent id params (i.e. :user_id => 2)
# File lib/authorized_rails_scaffolds/macros/route_example_macros.rb, line 56 def example_parent_values(use_shallow_route=false) example_parent_values = {} parent_models = use_shallow_route ? parent_model_names[0..-2] : parent_model_names parent_models.each_with_index do |parent_model, index| example_parent_values["#{parent_model}_id"] = index + 2 end example_parent_values end