Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails数据库条目,值都是问号_Ruby On Rails_Database_Json - Fatal编程技术网

Ruby on rails Rails数据库条目,值都是问号

Ruby on rails Rails数据库条目,值都是问号,ruby-on-rails,database,json,Ruby On Rails,Database,Json,我试图在rails中运行一个create方法,将项目插入数据库。我的创建代码如下所示: def create @song = Song.create ( { :song => params[:song], :artist => params[:artist], :album => params[:album], :song_id => params[:song_id], :longitude => params[:longitude], :l

我试图在rails中运行一个create方法,将项目插入数据库。我的创建代码如下所示:

def create
  @song = Song.create ( { :song => params[:song],
  :artist => params[:artist],
  :album => params[:album],
  :song_id => params[:song_id],
  :longitude => params[:longitude],
  :latitude => params[:latitude],
  :stream_url => params[:stream_url],
  :art_url => params[:art_url] } )

  respond_to do |format|
    if @song.save
      format.json { render :json => @song, :status => :created, :location => @song }
    else
      format.json { render :json => @song.errors, :status => :unprocessable_entity }
    end
  end
end
但是,我收到以下错误消息。如何确保插入的内容是我想要的

Started POST "/create" for 127.0.0.1 at Sun May 19 03:09:21 -0400 2013
Processing by SongsController#create as */*
Parameters: {"longitude"=>-72.6600766181946, "latitude"=>41.5570384662233, "album"=>"Get Lucky", "song"=>"Get Lucky", "artist"=>"Daft Punk", "stream_url"=>"http://api.7digital.com/1.2/track/preview?country=US&trackId=28905854&oauth_consumer_key=7dkn3ygtanwv", "art_url"=>"http://cdn.7static.com/static/img/sleeveart/00/026/861/0002686113_100.jpg", "song_id"=>28905854}
WARNING: Can't verify CSRF token authenticity
(0.1ms)  begin transaction
SQL (0.7ms)  INSERT INTO "songs" ("address", "album", "art_url", "artist", "created_at", "latitude", "longitude", "song", "song_id", "stream_url", "updated_at", "user") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)  [["address", "2-16 McConaughy Drive, Wesleyan University, Middletown, CT 06457, USA"], ["album", "Get Lucky"], ["art_url", "http://cdn.7static.com/static/img/sleeveart/00/026/861/0002686113_100.jpg"], ["artist", "Daft Punk"], ["created_at", Sun, 19 May 2013 07:09:21 UTC +00:00], ["latitude", 41.5570384662233], ["longitude", -72.6600766181946], ["song", "Get Lucky"], ["song_id", 28905854], ["stream_url", "http://api.7digital.com/1.2/track/preview?country=US&trackId=28905854&oauth_consumer_key=7dkn3ygtanwv"], ["updated_at", Sun, 19 May 2013 07:09:21 UTC +00:00], ["user", nil]]
(47.1ms)  commit transaction
(0.1ms)  begin transaction
(0.1ms)  commit transaction
Completed 201 Created in 664ms (Views: 1.8ms | ActiveRecord: 48.8ms)

->
201已完成创建

没有错误消息。记录已保存

VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ...values ->...
这些问号是紧跟其后的值的占位符。这是正常的行为

每个问号按其读取顺序替换为以下值。向右滚动查看这些值。看起来一切都在那里

WARNING: Can't verify CSRF token authenticity

这是一个安全问题。您是否在布局中包含了

请显示制作表单的相应视图。-1用于粘贴向右滚动的代码。@AmitKumarGupta如果您认为换行可以改进,请编辑帖子。我认为在这种情况下,长卷轴更容易阅读。投票否决没有帮助(除非你的评论是为了吸引你自己的选票)。我可以编辑一些格式不好阅读的帖子,但我没有时间对每一篇都这样做。向下投票有助于向OP提供关于设置帖子格式的反馈,这样更容易阅读,也更容易让人们帮助他。你指责我设计我的评论来吸引选票?我在努力想象你的思维过程。人们都是这样做的吗?我的评论中哪一部分对投票甚至有点“吸引力”?