Static pages in Ruby on Rails

后端 未结 9 1043
终归单人心
终归单人心 2020-12-04 05:47

What are the standard way of making a Ruby on Rails application that will have pages such as

  • Home
  • About
  • Contact

I would appric

相关标签:
9条回答
  • 2020-12-04 06:18

    For more you can create static pages using Jekyll bootstrap or also Jekyll using Danger blog

    Refer it is very helpful.

    0 讨论(0)
  • 2020-12-04 06:19

    I'd suggest adding your pages in the public folder so as to be served directly without having to pass through rails at all. I'm not an expert though so I'm not sure if this could have any cons if the page is static.

    0 讨论(0)
  • 2020-12-04 06:23

    config/routes.rb

    get ':id', to: 'pages#show'
    

    app/controllers/pages_controller.rb

    class PagesController < ApplicationController
      def show
        begin
          render params[:id]
        rescue ActionView::MissingTemplate
          render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found
        end
      end
    end
    

    Then place your static pages in app/views/pages/{name}.html.erb (or whatever template format.)

    0 讨论(0)
提交回复
热议问题