Reputation: 353
I want to create own customized generator for scafflod so that i can change the default layout of generated .html.erb or .html.haml for a particular application. I want to customize the layouts
Upvotes: 0
Views: 676
Reputation: 6025
There is some pretty nice stuff you can do with this. Problem is it is very badly documented, but once you know where to store the various template files, you're on the move:
It all starts in lib/templates
lib/templates/active_record/model/model.rb contains the model template
lib/templates/factory_girl/model/fixtures.erb contains the factory girl template
lib/templates/rails/scaffold_controller/controller.rb the controller
lib/templates/rspec/model/model_spec.rb the rspec model
lib/templates/rspec/scaffold/controller_spec.rb the rspec controller
lib/templates/haml/scaffold/_form.html.haml the views (idem dito for edit, index, new and show)
If you need more info on the templates, just let me know!
Upvotes: 0
Reputation: 1260
Making generators is a good idea when you want a specific layout applied to few of your resources. It might be like you have an normal user section and admin user section with different layouts.
You may have a good reference of making a generator from here:http://railscasts.com/episodes/218-making-generators-in-rails-3?view=asciicast
Upvotes: 3