我试图将我的应用分为两个版本。
一种是使用CDN,另一种是使用资产脚本和CSS。

对于CDN,是否仍然可以将所有CDN行拆分为其他文件,并在application.haml中设置链接以使其干净。

这是application.haml(或html)

%html
  %head
    %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
    = csrf_meta_tags
    %link{:href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css", :rel => "stylesheet"}/
    Optional Theme
    %link{:href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css", :rel => "stylesheet"}/
    %link{:href => "https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css", :rel => "stylesheet"}/
    %link{:href => "https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.2/css/AdminLTE.css", :rel => "stylesheet"}/
    %link{:href => "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css\n", :rel => "stylesheet"}/
    %link{:href => "https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic", :rel => "stylesheet"}/

    %script{:crossorigin => "anonymous", :integrity => "sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=", :src => "https://code.jquery.com/jquery-3.2.1.min.js"}
    %script{:crossorigin => "anonymous", :integrity => "sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=", :src => "https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"}
    %script{:src => "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/popper.min.js"}
    %script{:crossorigin => "anonymous", :integrity => "sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa", :src => "//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"}
    %script{:src => "https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.js"}
    %script{:src => "https://cdnjs.cloudflare.com/ajax/libs/jQuery-slimScroll/1.3.8/jquery.slimscroll.js"}
    %script{:src => "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.3/moment.min.js"}

    = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
    = javascript_include_tag "application", 'data-turbolinks-track': 'reload'


  %body.hold-transition.skin-yellow.sidebar-mini
    .wrapper
      = render "layouts/navigation/header"
      = render "layouts/navigation/sidebar"
      .content-wrapper
        = yield
      = render 'layouts/navigation/footer'

最佳答案

您可以为使用单独资产的其他版本创建单独的控制器。

创建versionb_controller.rb并更新routes.rb

添加文件夹/views/versionb

添加您的视图/views/versionb/index.html.erb

最后,在布局下添加其他版本的布局并另存为/layouts/versionb.html.erb

09-12 00:35