Method: Jets::Router::MethodCreator::Code#param_name

Defined in:
lib/jets/router/method_creator/code.rb

#param_name(name) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/jets/router/method_creator/code.rb', line 78

def param_name(name)
  # split('/').last for case:
  #
  #   resources :posts, prefix: "articles", only: :index do
  #     resources :comments, only: :new
  #   end
  #
  # Since the prefix at the scope level is added to the posts item, which results in:
  #
  #   param_name("articles/posts")
  #
  # We drop the articles prefix portion. The resources items can only be words with no /.
  #
  name.to_s.split('/').last.singularize + "_id"
end