我有两个模型通过他们共享的foreign_key
属性加入。
# app/models/building.rb
belongs_to :building_basic_info, primary_key: "name", foreign_key:"name"
# app/models/building_basic_info.rb
has_many :buildings, primary_key: "name", foreign_key:"name"
我尝试编写一个工厂,创建building
和building_basic_info
并通过属性name
关联它们。
FactoryGirl.define do
factory :building do
name "cannon"
factory :building_with_bbi do
name "cannon"
end
end
end
building = build_stubbed(:building)
building.building_basic_info
# => nil... but I want it to return the associated building_basic_info object
非常感谢任何帮助。
答案 0 :(得分:1)
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]