LoginSignup
4
6

More than 3 years have passed since last update.

high_voltageで利用規約等の静的ページを作る

Last updated at Posted at 2020-01-19

high_voltageで静的ページ(プライバシーポリシー、利用規約など)作成

routesとcontrollerの記述不要
headerやfooterを適用したい場合

gem high_voltage

routes.rb
/pages/*id 

を自動生成してくれる。rails routesで確認しよう
routes.rbには記述しないでいい

つまづいたところ

Disabling routes
The default routes can be completely removed by setting the routes to false:

# config/initializers/high_voltage.rb
HighVoltage.configure do |config|
  config.routes = false
end

※high_voltageのgithub参照

config.routes = false
はhigh_voltageのルートを使えなくするという意味。ここを読まずにコントローラーを作成したりルーティングを記述したりして複雑にしてしまっていた。

high_voltageのgithubやREAD.MEを参考にしてよく読む。

レイアウト指定

initializer.rb
config.layout = 'customer' 
#customer.html.slimがheader footerが書かれているlayout配下のfile

で適用したいレイアウトを指定

views/pages内に

confirm.html.slim
=link_to 'プライバシーポリシー', page_path('privacypolicy')
confirm.html.slim
=link_to '利用規約', page_path('terms')

と記述する

リンクごとにpages/privacyやpages/termsが表示されるようになります。

コピペじゃなくてなぜ動いているかを考えよう(自戒)

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6