Reputation: 15002
Every time I use scaffold
to generate related files.
I have to modify the *.html.erb
to *.html.haml
and change the content to my preference layout.
Is there any better practice to achieve this ?
Thanks.
For example, I have the these columns in my model :excel, :model, :result_file, :user_id, :version, :xml
.
I omit the default index.html.erb
file (the scaffold
generated it for me).
and I will change the index.html.erb
in my custom default layout.
I'd rather every time the scaffold will generate this pattern for me.
I know I can modified the template file under my .rvm
~/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/generators/erb/scaffold
But is it a good practice ?
%h1 ND
%div{:class => "hero-unit"}
%large
使用前請先安裝 Firefox plugin
%h2.center
= link_to "新增一筆測試", new_nd_multi_lang_path, |
:class=> "btn btn-primary autotest"
%table#rf_tbl.table.table-condensed.table-striped
%tr
%th Date
%th User
%th Model
%th Version
%th Excel
%th Xml
%th Result file
%th
%th
%th
- @nd_multi_langs.each do |nd_multi_lang|
%tr.center
%td= nd_multi_lang.created_at.strftime("%Y-%m-%d %H:%M")
%td= nd_multi_lang.user.email
%td= nd_multi_lang.model
%td= nd_multi_lang.version
%td
= link_to 'Excel', nd_multi_lang.excel.to_s
%td
= link_to 'XML', nd_multi_lang.xml.to_s
%td
= link_to 'Download', nd_multi_lang.result_file.to_s, :class=> "btn btn-info"
%br/
Upvotes: 0
Views: 37
Reputation: 891
Using the gem for haml-rails, should do that by default.
You editted your question to ask something entirely different >.<
Here is a guide to answer to your new question.
Upvotes: 1