If you are doing personal development, you will create terms of use and privacy policy. At that time, it is troublesome to prepare a controller for that purpose and write the routing. In that case, use the gem `` `high_voltage```!
Add'high_voltage' to Gemfile
$ docker-compose run app bundle install
I'm using Docker to build the environment. Depending on how you write Dockerfile and docker-compose.yml, if you rewrite Gemfile, you need to start over from build. I will omit this area this time.
app/views/pages
If the directory does not exist, create it.
$ mkdir -p app/views/pages
Create the file of the page you want to link, this time we will create the terms of use with haml. Replace the template engine from time to time.
$ touch app/views/pages/terms.html.haml
Write content.
haml:tearms.html.haml
.term-wrapper
%h1.uk-text-center Terms of Service
%p These Terms of Use (hereinafter referred to as "Terms of Use") are professional! (Hereinafter referred to as "the secretariat") defines the terms of use of the service provided on this website (hereinafter referred to as "this service"). Registered users (hereinafter referred to as "users") are required to use this service in accordance with this agreement.
%h2 Article 1 (applicable)
%ol
%li This agreement shall apply to all relationships related to the use of this service between the user and this secretariat.
%li The secretariat may make various provisions (hereinafter referred to as "individual provisions") regarding this service, such as rules for use in addition to this agreement. These individual provisions shall form part of this agreement regardless of their name.
%li If the provisions of this agreement contradict the provisions of the individual provisions of the preceding article, the provisions of the individual provisions shall prevail unless otherwise specified in the individual provisions.
%h2 Article 2 (Registration)
%ol
......(abridgement)
When you put a link, you can write the path as page_about ('terms').
haml:home.html.haml
= link_to 'Terms of service', page_path('terms')
Looking at the routing,
Prefix Verb URI Pattern Controller#Action
page GET /pages/*id high_voltage/pages#show
You can see that it is.
This completes the Terms of Service page for the time being! !!
The default is https://hogehoge.com/pages/terms, so if you want to change this to hogehoge.com/terms
, create config / initializers / high_voltage.rb and do the following: It is described as follows.
high_voltage.rb
HighVoltage.configure do |config|
config.route_drawer = HighVoltage::RouteDrawers::Root
end
Looking at the routing,
Prefix Verb URI Pattern Controller#Action
page GET /*id high_voltage/pages#show
You can see that the pages are gone.
We output what we have learned every day! !! If you have any suggestions, I would appreciate it if you could comment! !!
Recommended Posts