---
# System prepended metadata

title: '[Rails4][views]讓整個專案全域套用自訂的版型'
tags: [Rails4]

---

# [Rails4][views]讓整個專案全域套用自訂的版型

###### tags: `Rails4`


假設有在app/views/layouts新增了一個frontend.html.erb,
想要將它設為views的預設版型,除了直接修改application.html.erb外,

還有另一種方式.

因為所有controller預設都是繼承自application_controller.rb,

只要修改該檔案即可.

app/controllers/application_controller.rb
```ruby
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  layout "frontend"   #<----新增此行
end
```

