大家下午好
我正在尝试建立一个烟草审查申请,除了学习更多的东西之外别无他法.我一直在努力建立在Rails教程书中学到的东西,但是我不断遇到砖墙和我不理解的陷阱.我通常可以为nil克服未定义的方法`'something':NilClass和我有的其他问题,但这个真的让我难过,因为我的测试通过了.
我的测试
review_test.rb
require 'test_helper'
class ReviewTest < ActiveSupport::TestCase
# Define a user for the test
def setup
@user = users(:shaun)
@review = @user.reviews.build( rating: 5,
comment:"This is a super snus",
tobacco_id: 1)
end
# Test should be valid
test "should be valid" do
assert @review.valid?
end
# Test the user id is present
test "user id should be present" do
@review.user_id = nil
assert_not @review.valid?
end
# Test the tobacco id is present
test "tobacco id should be …Run Code Online (Sandbox Code Playgroud) 我问这个问题的原因是为了帮助我解决一个非常烦人的语法错误.我正在使用第11章,因此我可以在我的新网站上使用图像构建一个博客部分,当我尝试添加类时,一切都有效:"img-responsive"到这一行.
<%= image_tag image_article.picture.url if image_article.picture? %>
Run Code Online (Sandbox Code Playgroud)
我只是无法弄清楚添加类的正确语法:"img-responsive".
图像上传很好,但它突破了col-md-6容器,并显示打破页面布局的完整图像,因此除了我尝试添加类时,它们都在本地工作:括号中的"img-responsive"或括号,我尝试的每一种方式都会崩溃应用程序,所以我被困住了.我已经四处寻找其他解决方案,我发现了一个与carrierwave配合使用的宝石......
但这似乎就像用大锤敲打坚果一样,到目前为止我已经想到的所有其他问题,但这真的很烦人.我找不到适合响应图像的载波调整大小的任何东西,当然我可以使用img-responsive类?
关心肖恩