小编cho*_*icz的帖子

如何在Rails seeds.rb中清除整个数据库

完成此任务的最佳方法是什么?至于现在,我正在使用:

Role.delete_all
User.delete_all
...
Run Code Online (Sandbox Code Playgroud)

但如何清除habtm talbes?像roles_users一样

更新的答案

我认为ream88的回答最准确地回答了我的问题,但可能是bestidea遵循coreyward建议来使用单独的rake任务并将seeds.rb留给播种数据.

这是来自ream88的更新答案,它不删除schema_migrations表格.

ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table|
  # MySQL
  ActiveRecord::Base.connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"

  # SQLite
  # ActiveRecord::Base.connection.execute("DELETE FROM #{table}") unless table == "schema_migrations"
end
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助!

ruby-on-rails

23
推荐指数
2
解决办法
2万
查看次数

当位置改变时,CSS转换在Firefox中不起作用

我发现了烦人的bug.我试图在父元素的位置发生变化的同时动画子元素的CSS属性(在示例中它是从固定到绝对).这在Webkit浏览器中没有问题,但在Firefox(v.17.0.1)中没有动画过渡.

jsFiddle示例:http://jsfiddle.net/chodorowicz/bc2YC/5/

有什么解决方案可以让它在FF中运行吗?

编辑 它已在Firefox 34中修复 https://bugzilla.mozilla.org/show_bug.cgi?id=625289

CSS

#container {
    position:fixed; left:100px; top:100px;
}
#container.some_state_position {
    position:absolute;
}
.box {
    width:100px; height:100px;
    background:blue;
}

.some_state .box {
    background:red; width:50px; height:50px;
}

img, .box  {
    -webkit-transition:all 1.5s ease;
    -moz-transition:all 1.5s ease;
    -ms-transition:all 1.5s ease;
    transition:all 1.5s ease;
}
img {width:100%;}
.some_state .other_container img {
    width:50%;
}
Run Code Online (Sandbox Code Playgroud)

css firefox transitions

13
推荐指数
1
解决办法
4784
查看次数

标签 统计

css ×1

firefox ×1

ruby-on-rails ×1

transitions ×1