Rails 3.1 - 更改默认脚手架视图和模板 [英] Rails 3.1 - changing default scaffold views and template

查看:27
本文介绍了Rails 3.1 - 更改默认脚手架视图和模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 rails 3.1 与 Zune Foundation 模板和 haml 一起使用.我试图找到更改默认脚手架视图模板以使用我想要的 css 的方法,这样我就可以在不手动更改视图的情况下获得与所有脚手架一致的外观.我也用 simple_form.

I'm using rails 3.1 with Zune Foundation templates and haml. I have tried to fiend ways to change the default scaffold view templates to use css I want so I get a consistent look with all scaffold without manually changing the view. I also use simple_form.

由于我不想编写自己的生成器,是否有一些简单和/或推荐的方法来处理这个问题?

As I don't want to program my own generators, is there some easy and/or recommended ways to handle this?

约翰

推荐答案

您可以通过在 Rails 应用的lib/templates/erb/scaffold"文件夹中创建自己的模板来覆盖默认视图模板.

You can override default view templates by creating your own templates in 'lib/templates/erb/scaffold' folder of your rails app.

  lib/templates/erb/scaffold/_form.html.erb
  lib/templates/erb/scaffold/edit.html.erb
  lib/templates/erb/scaffold/index.html.erb
  lib/templates/erb/scaffold/new.html.erb
  lib/templates/erb/scaffold/show.html.erb

可以在此处找到默认模板 - https://github.com/rails/rails/tree/master/railties/lib/rails/generators/erb/scaffold/templates

The default templates can be found here - https://github.com/rails/rails/tree/master/railties/lib/rails/generators/erb/scaffold/templates

这篇关于Rails 3.1 - 更改默认脚手架视图和模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆