Create extension with the name different from model name

39 views
Skip to first unread message

David Chen

unread,
Jul 22, 2013, 4:59:36 AM7/22/13
to refine...@googlegroups.com
Hi,

I have a requirement that I need to create an extension with 2 models. But I don't want the extension name to be the same as any model name.

For example, I wish the extension name is "Shop". It contains 2 models, "Product" and "Customer".

But I can't do it with "refinery:engine" generator. I've tried several way:

With "rails g refinery:engine Product name:string --event Shop --namespace Shop", it tells me the extension with name Shop doesn't exist.
With "rails g refinery:engine Shop", it tells me to specify a name and at least one field.

What I really want, is putting the models, controllers, views under the same namespace. So when I use a model, I don't need to type "Refinery::Products::Product" and "Refinery::Customers::Customer" but "Refinery::Shop::Product" and "Refinery::Shop::Customer". That makes more sense.


Anton Kuzmin

unread,
Mar 30, 2016, 3:35:26 PM3/30/16
to Refinery CMS
I would also like to know.

понедельник, 22 июля 2013 г., 18:59:36 UTC+10 пользователь David Chen написал:

Brice Sanchez

unread,
Mar 30, 2016, 4:51:13 PM3/30/16
to Refinery CMS
You could start to read the source code of my extension : https://github.com/bisscomm/refinerycms-products

I don't know if the Engine generator could do what you want, i mainly an engine kickstarter.

Anita Graham

unread,
Apr 1, 2016, 12:06:37 AM4/1/16
to Refinery CMS
I have done it by building an engine with a dummy model for the engine name, then using the namespace option to add models to that engine.
Then delete references to the dummy model if you don't want it.

rails g refinery:engine shop name:string, logo:image
rails g refinery:engine customer name:string address:string  --namespace=shop --extension=shop
rails g refinery:engine product name:string price:integer  --namespace=shop --extension=shop



Anita
Reply all
Reply to author
Forward
0 new messages