I'm confused about routes and Rails 5. I have this in my controller ...
respond_to do |format|
if @my_event.save
puts "saved successfully."
format.html { redirect_to my_events, notice: 'Saved successfully.' }
as you can see from "rake routes", "my_events" is defined.
macbook1:myproject nataliab$ rake routes
Prefix Verb URI Pattern Controller#Action
...
my_events GET /my_events(.:format) my_events#index
Yet when the above runs, I get the error
undefined local variable or method `my_events' for #<MyEventsController:0x007fa3b9479348>
What's the right way to reference my route from my controller?
在您的控制器中,尝试将my_events交换为@my_event。
format.html { redirect_to @my_event, notice: 'Saved successfully.' }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.