I have created a Rails Engine (as per the Rails Guides) using:
rails plugin new address_book --full --mountable
I proceeded to create a controller for the Engine called pages
with a single action (called temp
) to display a single view, namely app/views/address_book/pages/temp.html.erb
The Engine's config/routes.rb is:
AddressBook::Engine.routes.draw do
match :temp, to: "pages#temp"
end
In the parent application I added the following in it's routes.rb file:
mount AddressBook::Engine => "/address_book", as: "address_book"
In an action of one of the parent application's controllers I have the following call to a view belonging to the Engine:
redirect_to address_book.temp_path
Now, even though rake routes
displays the Engine's path, when I try to execute the action from the browser I keep getting the error:
undefined local variable or method `address_book'
for the line redirect_to address_book.temp_path
The result of rake routes contains the following:
address_book /address_book AddressBook::Engine
Routes for AddressBook::Engine:
temp /temp(.:format) address_book/pages#temp
I cannot seem to understand what I'm missing, so any help would be greatly appreciated.