dio_bless
dio_bless

Reputation: 475

Getting param in controller from GET request in Ruby on rails

I have in routes.rb

namespace :point do
  resources :points do
    get 'history'
end

In the view:

= link_to 'History', point_point_history_path(object)

Url looks like "/point/points/123456/history"

But in controller i cannot get it:

def history

raise params[:id].inspect

end

it returns nil.

What have i do wrong?

Upvotes: 0

Views: 1329

Answers (1)

deefour
deefour

Reputation: 35360

The route generated is

point_point_history GET    /point/points/:point_id/history(.:format)    point/points#history

So you want to request params[:point_id], not params[:id]

Upvotes: 2

Related Questions