rails-admin-scaffold icon indicating copy to clipboard operation
rails-admin-scaffold copied to clipboard

Generator templates customization seems to be not working as described in readme

Open dhampik opened this issue 9 years ago • 11 comments

According to report in comment on my blog, generator templates customization does not work as described in readme:

How to customize your generator templates

Put the '_form.html.erb.erb', 'edit.html.erb.erb', 'index.html.erb.erb', 'new.html.erb.erb', 'show.html.erb.erb' into '/lib/templates/admin/scaffold_controller/views/erb/'

Then the generator will use those templates to generate scaffold.

Should check it and fix it.

dhampik avatar May 04 '15 04:05 dhampik

Fix it please, we really need this case :)

kuzevanoff avatar May 18 '15 00:05 kuzevanoff

Can you post detailed workflow to reproduce bug?

For me it is work fine. I use custom haml_bootstrap templates in my project. And I check customisation of erb templates. From Gemfile.lock:

rails (4.2.1)
rails-admin-scaffold (0.1.0)

maslenkov avatar May 18 '15 20:05 maslenkov

Try to add erb templates and generate scaffold.

kuzevanoff avatar May 18 '15 20:05 kuzevanoff

For me it is work correct. My actions: into console:

> mkdir lib/templates/admin/scaffold_controller/views/erb
> cp ~/.rvm/gems/ruby-2.2.2@GEMSET/gems/rails-admin-scaffold-0.1.0/lib/generators/admin/scaffold_controller/templates/views/erb/* lib/templates/admin/scaffold_controller/views/erb

in all templates add as first line foo into console:

> rails g admin:scaffold_controller foo
=> 
...
create  app/views/admin/foos/index.html.erb
...

I check generated files and they contain foo as first line.

If I call rails g scaffold model_name it should not take your custom templates because it is use another generator. You should check rails docs about scaffold templates customisation. It says:

If you generate another resource, you can see that we get exactly the same result! This is useful if you want to customize your scaffold templates and/or layout by just creating edit.html.erb, index.html.erb and so on inside lib/templates/erb/scaffold.

maslenkov avatar May 18 '15 20:05 maslenkov

Can u archive me your app an send to [email protected] Thank u

kuzevanoff avatar May 18 '15 20:05 kuzevanoff

I created repo on github - https://github.com/maslenkov/templates_example

maslenkov avatar May 18 '15 20:05 maslenkov

Thank u. So for u i need to configurate my rails app correctly?

kuzevanoff avatar May 18 '15 21:05 kuzevanoff

I think, this is a problem with paths to templates. I could be wrong.

maslenkov avatar May 18 '15 21:05 maslenkov

I can record some screencast if u need

kuzevanoff avatar May 18 '15 21:05 kuzevanoff

Yes. It is ok. I send you email.

maslenkov avatar May 18 '15 21:05 maslenkov

its was my mistake. Its important to call like index.html.erb.erb (erb.erb) now for me its work fine. Thanks.

kuzevanoff avatar May 19 '15 20:05 kuzevanoff