dhampik / rails-admin-scaffold

Rails generator which allows to scaffold admin controllers, views with proper (non-namespaced) models, helpers, tests and routes
MIT License
92 stars 37 forks source link

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

Open dhampik opened 9 years ago

dhampik commented 9 years ago

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.

kuzevanoff commented 9 years ago

Fix it please, we really need this case :)

maslenkov commented 9 years ago

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)
kuzevanoff commented 9 years ago

Try to add erb templates and generate scaffold.

maslenkov commented 9 years ago

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.

kuzevanoff commented 9 years ago

Can u archive me your app an send to pangodfather@Gmail.com Thank u

maslenkov commented 9 years ago

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

kuzevanoff commented 9 years ago

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

maslenkov commented 9 years ago

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

kuzevanoff commented 9 years ago

I can record some screencast if u need

maslenkov commented 9 years ago

Yes. It is ok. I send you email.

kuzevanoff commented 9 years ago

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