我有一个简单的rails 3 app和一个FB like按钮.我已经使用FB OG标签来获取图像在类似交易期间发布的其他相关信息.
当我在我的本地服务器上测试时和上传后,谎言会张贴Facebook的默认图像,并且不包含OG标记中的其他信息.
我看了几个关于此问题的其他问题,回顾了FB开发人员关于如何使用OG标签的说明,我确信我已经正确输入了它们.想知道是否还有另一个步骤或其他我想念的东西
我的头部标签就像这样
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>my title</title>
<meta property="og:title" content="My Site" />
<meta property="og:site_name" content="My Site" />
<meta property="og:url" content="http://www.mysite.com/"/>
<meta property="og:image" content="http://www.mysite.com/assets/image.png"/>
<meta property="og:type" content="ecommerce"/>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= favicon_link_tag "/favicon.ico" %>
<%= csrf_meta_tags %>
Run Code Online (Sandbox Code Playgroud)
身体的东西
我有几个属性(一个产品模型customer_type,customer_name,dept_type等...),我想用一些数据种子吧.
我的db/seeds.rb文件中有以下内容
Product.create(customer_type:'Retailer', customer_name: 'Walmart', dept_type: 'Grocery')
Run Code Online (Sandbox Code Playgroud)
我保存文件然后运行rake db:Seed我得到没有错误消息,但当我加载我的应用程序时,没有数据存在?我在这做错了什么?
我也试过rake db:setup,rake db:reset每次都没有返回错误信息,但数据没有加载.
更新我修改了我的db种子文件,看起来像这样
Product.create!(customer_type:'Retailer', customer_name: 'Walmart', dept_type: 'Grocery')
Run Code Online (Sandbox Code Playgroud)
当我运行rake db:reset我得到错误"验证失败:客户类型不包含在列表中"
我的产品模型文件带有验证
class Product < ActiveRecord::Base
attr_accessible :customer_type
has_many :line_items
has_many :orders, through: :line_items
CUSTOMER_TYPES = ["Retailer", "Manufacturer"]
validates :customer_type, inclusion: CUSTOMER_TYPES
Run Code Online (Sandbox Code Playgroud)
我尝试使用客户类型值Retailer和制造商没有运气来播种数据库