Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy way to cusomize views of Rails' scaffold generator?

I know how to create a new generator in Rails. However, I simply want to tweak the views a bit. Is there an easy way to do this? I guess I could go into the directory in my operating system where Rails resides and modify those files (I assume that's easy). But then those changes will apply to every Rails project, not just the one I care about at the moment. And it'll get wiped away when I update Rails (frequently).

Using Rails 3.2.13, but happy to upgrade to 4.0 beta if that helps.

like image 745
at. Avatar asked Nov 03 '22 01:11

at.


1 Answers

You can find the answer in this RailsCast, note particularly the section on "Customizing Templates". You create the files in your Rails root lib/ directory, so it won't apply to every app, just your current one, and it will be independent of Rails versions.

like image 171
ezraball Avatar answered Nov 09 '22 08:11

ezraball