3

I am trying to separate the model of my application to be more reusable by using Rails engines.

I have created a Common engine which has all my models for my application that I want to share between a Website and API project.

Because of the nature of how Rails engine's namespace all your models by default I was wondering if there was a way to just make it simpler to just not namespace any of the models included by the engine.

I wish to simplify my model and not have to rewrite my application to add Namespace prefixes to all my models, and just share the engine as a global model for my other applications.

I have tried removing "isolate_namespace" from the engine but I still have problems with routes in my views. eg.

<%= link_to user.name, user %>

produces an error looking for url in the namespace of common

undefined method common_user_path

Is there a better way to achieve this?

4

1 に答える 1

6

I resolved this by creating a new Engine with the command line

rails plugin new forum --full

This will share models, controllers etc, without namespaces.

于 2013-01-09T06:00:59.720 に答える