CaptainCarl
CaptainCarl

Reputation: 3489

Route not using custom method in controller

I have a route which goes to /messages/9/reply/ with a custom route in my routes.rb. But the method isn't used nor is he looking for it(REmoving my method doesn't throw an error)

The view, however, IS found. What could cause this?

My route: get "/messages/:id/reply/" => "messages#reply", :as => :messages_reply

Upvotes: 0

Views: 32

Answers (2)

Kirti Thorat
Kirti Thorat

Reputation: 53018

For the given route,

get "/messages/:id/reply/" => "messages#reply", :as => :messages_reply

An action / method named reply in MessagesController would be invoked. Make sure that your method name matches to it.

And if you don't have any explicit call to render or redirect_to in reply method then by default a view named render.html.*** (where *** is template handler extension, like erb, haml) from app/views/messages directory would be rendered.

Upvotes: 1

Dmitry
Dmitry

Reputation: 163

Can you post the whole part of route file which is dedicated to messaging?

I would write this thingie in a more rails way:

resources :messages do
    member do
        get :reply
    end
end

Assuming that you need REST actions for messages

Upvotes: 0

Related Questions