Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routes path helper method

I created a new route, like this:

  resources :animals do
    member do
      get ':id/resumed_rep_life', :action => 'resumed_rep_life'
    end
  end
  match '/animals/:id/resumed_rep_life' => "animals#resumed_rep_life"

How can I made a link for it?

I tried resumed_rep_life_animal_path(animal) but it does not work (method not found). Are my routing correct?

like image 386
caarlos0 Avatar asked Feb 17 '26 14:02

caarlos0


1 Answers

Change this line:

match '/animals/:id/resumed_rep_life' => "animals#resumed_rep_life"

to this:

match '/animals/:id/resumed_rep_life' => "animals#resumed_rep_life", :as => 'resumed_rep_life_animal'
like image 112
weexpectedTHIS Avatar answered Feb 20 '26 09:02

weexpectedTHIS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!