我正在使用虚荣宝石做一些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
与虚荣相关的其他文件:
#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
等 谢谢你们,任何帮助都会很棒。
答案 0 :(得分:0)
这最终成了我的错误(惊喜)。
默认情况下,虚荣不会使用config/vanity.rb
。这一切都需要进入config/application.rb
现在一切都很好。