我正在使用虚荣宝石进行一些 AB 测试,但我的报告一团糟。自动生成的 css 和视图的宽度为 40em,我想更改它。按照 我跑的虚荣文档
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
与虚荣相关的其他文件:
#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
等谢谢大家,任何帮助都会很大。