2013-12-10 47 views
0

每次我使用scaffold生成相關文件時。如何更改Rails上新創建的默認視圖

我必須修改*.html.erb*.html.haml並將內容更改爲我的首選項佈局。

有沒有更好的做法來實現這一目標?

謝謝。

例如,我在我的模型:excel, :model, :result_file, :user_id, :version, :xml中有這些列。

我省略了默認的index.html.erb文件(scaffold爲我生成了它)。

我會在我的自定義默認佈局中更改index.html.erb

我寧願每一次腳手架都會爲我產生這種模式。

我知道我可以在我的.rvm

~/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.13/lib/rails/generators/erb/scaffold

修改的模板文件,但它是一個好的做法呢?

%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/ 

回答

相關問題