【问题标题】:Custom Vanity views being ignored自定义虚荣视图被忽略
【发布时间】:2017-04-05 04:10:47
【问题描述】:

我正在使用虚荣宝石进行一些 AB 测试,但我的报告一团糟。自动生成的 css 和视图的宽度为 40em,我想更改它。关注Vanity Documentation 我跑了

rails g vanity:views

它生成了所有需要的文件,并进行了相应的编辑。 但是,我仍然没有看到更改,我无法弄清楚为什么 rails 仍然使用 gem 文件夹中的默认值,而不是视图中的默认值。

Started GET "/vanity" for ::1 at 2016-11-21 12:07:19 -0500 Processing by VanityController#index as HTML W, [2016-11-21T12:07:19.231036 #2616] WARN -- : No default alternative specified; choosing school_lower as default. AdminUser Load (1.4ms) SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = $1 ORDER BY "admin_users"."id" ASC LIMIT 1 [["id", 32]] Rendered /Users/lowellmower/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/vanity-2.2.6/lib/vanity/templates/_ab_test.erb (754.1ms) Rendered /Users/lowellmower/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/vanity-2.2.6/lib/vanity/templates/_experiment.erb (1013.5ms)

我什至在配置文件中明确添加了custom_template

#config/vanity.rb Vanity.configure do |config| config.templates_path = 'views/vanity' end

其他与Vanity相关的文件:

#routes.rb get '/vanity' =>'vanity#index' get '/vanity/participant/:id' => 'vanity#participant' post '/vanity/complete' post '/vanity/chooses' post '/vanity/reset' post '/vanity/enable' post '/vanity/disable' post '/vanity/add_participant' get '/vanity/image'

#app/controllers/vanity_controller.rb
class VanityController < ApplicationController
  include Vanity::Rails::Dashboard
  layout false # exclude this if you want to use your application layout

  before_action :authenticate_admin_user!

end

所有视图都在:

#app/views/vanity/_report.erb 

等 谢谢大家,任何帮助都会很重要。

【问题讨论】:

    标签: ruby-on-rails vanity


    【解决方案1】:

    这最终代表我犯了一个错误(惊讶)。 默认情况下,虚荣心不采用config/vanity.rb。这一切都需要进入config/application.rb 现在一切正常。

    【讨论】:

    • 这里的贡献者 - 很高兴你明白了,文档/自述文件可以更清楚吗?
    • 啊,你不认为你可以。这是我的疏忽,如果我没记错的话,文档说把它放在 application.rb 中,我只是继续把它放在 vanity.rb 中。
    猜你喜欢
    • 1970-01-01
    • 2010-09-10
    • 2014-10-09
    • 2013-10-10
    • 1970-01-01
    • 2016-11-23
    • 2021-05-13
    • 2010-10-04
    • 2017-05-12
    相关资源
    最近更新 更多