Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在学习 rails,但找不到搜索这个的好方法,因为 Google 不喜欢下划线。build_*作为前缀有什么作用?它是否为您附加的任何模型创建了初始化程序?
build_*
它与协会有关。您可以在子类的对象上使用它来构建父关联。你不能反过来使用它。
class Puppy belong_to :dog attr_accessor :name end class Dog has_many :puppies attr_accessor :name end p = Puppy.new(name: "baby") p.build_dog(name: "John)
我在<a>带有背景图像的标签上使用了特殊的链接效果:CSS。链接看起来不错,但该网站还包含很多<img>链接,这些链接也获得了 CSS。
<a>
<img>
我目前正在用 jQuery 解决这个问题:$("img").parent().css("background", "
$("img").parent().css("background", "