0

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.

pjmorse
  • 9,204
  • 9
  • 54
  • 124
Theo Scholiadis
  • 2,316
  • 2
  • 22
  • 33

1 Answers1

0

After a long process of trial and error (and shutting down the PC for the night) I realised that all I needed to do was restart the server

Hope this post help others with the same stumbling block.

Theo Scholiadis
  • 2,316
  • 2
  • 22
  • 33