0

I am creating rails application and I separated the application into two engines. Application uses Devise gem for user registration and authorization. Devise gem is connected in the root app and admin side is lying inside one of the engines. But admin side layout is still inside the root application. If I use this code <%= link_to edit_user_registration_path do %> in the admin layout it is showing me the following exception:

undefined local variable or method `edit_user_registration_path' 

at /app/views/layouts/admin.html.erb

Can someone please help me to solve this problem. What can be the reason for this outcome?

1
  • could you provide us with some more info like your model Commented Aug 18, 2014 at 12:52

2 Answers 2

1

i think you have messed up with routes.rb..let me give u a hint...

for /admin/posts and admin/posts#index and <%= link_to admin_posts_path do %> to work,your routes must have

  namespace :admin do
  resources :posts, :comments
end

but for something like(only url and helper/controller without admin) to work

`/admin/posts`  and     `posts#index` and  `<%= link_to posts_path do %>`

then ...your routes must have

  resources :posts, path: /admin/posts

so you must have this in your routes(using devise)

devise_for :users,:controllers => {:registrations => "users/devise/registrations"}

which will give you:-

edit_user_registration GET /users/edit(.:format) users/devise/registrations#edit

i think this should help you.

Sign up to request clarification or add additional context in comments.

1 Comment

@Rustery...always read the Readme...before installing/using any gem in rails..it helps
0

Additionally, if you your engine controller is referencing the parent's layout, you will have to specify the helper as such:

<%= link_to "Change password", main_app.edit_user_registration_path %>

Here's the exact explanation from the rails guide book:

or instance, the following example would go to the application's articles_path if that template was rendered from the application, or the engine's articles_path if it was rendered from the engine:

<%= link_to "Blog articles", articles_path %>

To make this route always use the engine's articles_path routing helper method, we must call the method on the routing proxy method that shares the same name as the engine.

<%= link_to "Blog articles", blorgh.articles_path %>

If you wish to reference the application inside the engine in a similar way, use the main_app helper:

<%= link_to "Home", main_app.root_path %>

If you were to use this inside an engine, it would always go to the application's root. If you were to leave off the main_app "routing proxy" method call, it could potentially go to the engine's or application's root, depending on where it was called from.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.