我想使用灯箱宝石,如fancybox或彩盒.两个宝石都要求在application.css中添加这一行
*= require colorbox-rails
Run Code Online (Sandbox Code Playgroud)
这是问题所在.我只有application.css.scss文件.我的所有css文件都是scss文件.我在application.css.scss中有import语句但没有*= require语句.添加上面的行会导致错误:
"*"之后的CSS无效:期望"{",是"= require colorb ..."
这是完整的application.css.scss
@import "bootstrap";
@import "welcome";
@import "sessions";
@import "users";
*= require colorbox-rails
Run Code Online (Sandbox Code Playgroud) 我有一个评论控制器和一个产品控制器.它在带有Forbidden Attributes错误的注释控制器的创建操作时失败.
我已从模型中删除了所有attr_accessible并将它们移动到控制器.还是有些不对劲.我无法弄清楚是什么.请任何人都可以告诉我我错过了什么.
@comment = @commentable.comments.new(params[:comment]) <--- Fail here
Run Code Online (Sandbox Code Playgroud)
Live Shell o/p来自更好的错误:
>> params[:comment]
=> {"content"=>"thanks"}
>> @commentable
=> #<Product id: 1, title: "Coffee Mug", description: "<p> This coffee mug blah blah", image_url: "http://coffee.com/en/8/82/The_P...", price: #<BigDecimal:7ff8769a9e00,'0.999E1',18(45)>, tags: nil, created_at: "2014-02-24 14:49:34", updated_at: "2014-02-24 14:49:34">
>> @commentable.comments
=> #<ActiveRecord::Associations::CollectionProxy []>
>> @commentable.comments.new(params[:comment])
!! #<ActiveModel::ForbiddenAttributesError: ActiveModel::ForbiddenAttributesError>
>>
Run Code Online (Sandbox Code Playgroud)
评论控制器:
class CommentsController < ApplicationController
def new
@comment = @commentable.comments.new
end
def create
@comment = @commentable.comments.new(params[:comment]) <-- fail here
if @comment.save
redirect_to product_path(params[:product_id])
else
render …Run Code Online (Sandbox Code Playgroud) 你好,我是红宝石新手:)我正在寻找一个解释,以理解在其语法中使用':'.
例如:
test "should create product" do
assert_difference('Product.count') do
post :create, product: @update
end
end
Run Code Online (Sandbox Code Playgroud)
我们什么时候做:something,而不是有something:什么区别.如果这是可谷歌的,请给我一些关于谷歌关于这个主题的关键字的一些指示.到目前为止,Ruby Colon的变化产生了许多无关的结果.