lastcat
lastcat

Reputation: 53

How do connect different http method to same action on routes.rb?

I am begginer for Ruby on Rails.I want to know how to connect different http request (to same url) to same action as follows.

now

resources :hoge do
  fuga do
    put :piyo
    patch :piyo
  end
end

I want

resources :hoge do
  fuga do
    put,patch :piyo
  end
end

Ruby enginners love 'DRY' mind so I think helper method exist like this.If don't exist, I want to know good helper method definition.

I think concernin routes.rb isn't I need.

Upvotes: 0

Views: 38

Answers (1)

spickermann
spickermann

Reputation: 106922

You could use match:

match 'piyo', via: [:put, :patch]

Upvotes: 1

Related Questions