我正在使用 rails 2.3.4、rubygems 1.3.6、activerecord 3.1.0、windows 7 home basic
这是我的代码:
def items
@products = ShopifyAPI::Product.find(:all)
@products.each do |a|
begin
@shop = Product.new(:title => a.title , :shop_id => a.id, :product_type => a.product_type)
@shop.save
rescue ActiveRecord::RecordNotUnique
redirect_to :action => "display_items"
end
end
@shop_items =Product.find(:all)
if session[:user_id]
@log = "Welcome Administrator!"
@logout="logout"
else
@log = "Admin Log in"
@logout=""
end
end
我在尝试保存 API 提供的数据时遇到错误“未初始化的常量 ActiveRecord::RecordNotUnique”。任何帮助,将不胜感激。谢谢你。