我有以下迁移文件 db\migrate\20100905201547_create_blocks.rb
如何专门回滚该迁移文件?
我有一个充满数据的开发Ruby on Rails数据库.我想删除所有内容并重建数据库.我正在考虑使用类似的东西:
rake db:recreate
Run Code Online (Sandbox Code Playgroud)
这可能吗?
给出如下字符串:
"The dog has a long tail, and it is RED!"
什么样的jQuery或JavaScript魔法可用于将空间最多只保留一个空间?
目标:
"The dog has a long tail, and it is RED!"
我有以下内容:
$(document).ready(function()
{
$("#select-all-teammembers").click(function() {
$("input[name=recipients\\[\\]]").attr('checked', true);
});
});
Run Code Online (Sandbox Code Playgroud)
我希望id="select-all-teammembers"点击时可以在已选中和未选中之间切换.想法?这不是几十行代码?
我有以下文件:
/spec/controllers/groups_controller_spec.rb
Run Code Online (Sandbox Code Playgroud)
在终端中使用什么命令来运行该规范以及在哪个目录中运行命令?
我的宝石文件:
# Test ENVIRONMENT GEMS
group :development, :test do
gem "autotest"
gem "rspec-rails", "~> 2.4"
gem "cucumber-rails", ">=0.3.2"
gem "webrat", ">=0.7.2"
gem 'factory_girl_rails'
gem 'email_spec'
end
Run Code Online (Sandbox Code Playgroud)
规格文件:
require 'spec_helper'
describe GroupsController do
include Devise::TestHelpers
describe "GET yourgroups" do
it "should be successful and return 3 items" do
Rails.logger.info 'HAIL MARRY'
get :yourgroups, :format => :json
response.should be_success
body = JSON.parse(response.body)
body.should have(3).items # @user1 has 3 permissions to 3 groups
end
end
end
Run Code Online (Sandbox Code Playgroud) 当我意识到你应该在视图中使用帮助器时,我需要一个帮助器在我的控制器中,因为我正在构建一个JSON对象来返回.
它有点像这样:
def xxxxx
@comments = Array.new
@c_comments.each do |comment|
@comments << {
:id => comment.id,
:content => html_format(comment.content)
}
end
render :json => @comments
end
Run Code Online (Sandbox Code Playgroud)
我怎样才能访问我的html_format助手?
我的页面完成加载后.我想让jQUery很好地滚动到页面底部,快速动画,而不是快速/摇晃.
我需要一个像这样的插件ScrollTo吗?或者是内置到jQuery中的一些如何?
Rails 3或Ruby是否有内置方法来检查变量是否为整数?
例如,
1.is_an_int #=> true
"dadadad@asdasd.net".is_an_int #=> false?
Run Code Online (Sandbox Code Playgroud) 我想为单选按钮的选定标签添加样式:
HTML:
<div class="radio-toolbar">
<label><input type="radio" value="all" checked>All</label>
<label><input type="radio" value="false">Open</label>
<label><input type="radio" value="true">Archived</label>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.radio-toolbar input[type="radio"] {display:none;}
.radio-toolbar label {
background:Red;
border:1px solid green;
padding:2px 10px;
}
.radio-toolbar label + input[type="radio"]:checked {
background:pink !important;
}
Run Code Online (Sandbox Code Playgroud)
我有什么想法我做错了吗?
我有一个复选框,在某些条件下,需要禁用.原来HTTP不会发布禁用的输入.
我怎么能绕过那个?提交输入,即使它被禁用并保持输入被禁用?