最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError (expected Hash (got String) for param `content' - Stack Overflow

programmeradmin2浏览0评论

I'm currently trying to add widgEditor to a form in ruby on rails however whenever I hit submit I get the following error:

TypeError (expected Hash (got String) for param `content'

The form code is as follows:

<div class="field">
<%= f.label :content %><br />
<%= f.text_area :content,  :cols => "20", :rows=>"4", :class=>"widgEditor" %>
</div>
<div class="actions">
    <%= f.submit %>
 </div>

has anyone got any experience with this issue?

I'm currently trying to add widgEditor to a form in ruby on rails however whenever I hit submit I get the following error:

TypeError (expected Hash (got String) for param `content'

The form code is as follows:

<div class="field">
<%= f.label :content %><br />
<%= f.text_area :content,  :cols => "20", :rows=>"4", :class=>"widgEditor" %>
</div>
<div class="actions">
    <%= f.submit %>
 </div>

has anyone got any experience with this issue?

Share Improve this question asked Oct 20, 2011 at 12:42 Jeff_HdJeff_Hd 2,2243 gold badges20 silver badges29 bronze badges 4
  • can you see what is being posted with firebug or chrome developerbar? – Manuel van Rijn Commented Oct 20, 2011 at 12:49
  • Sorry! Here it is: template_contentWidgToolbarSelectBlock: template%5Bcontent%5D:<p>I've </p><b>entered</b><p> some content here</p> template%5Bcontent%5DWidgEditor:true – Jeff_Hd Commented Oct 20, 2011 at 12:59
  • Can you past the complete form code. – Mahesh Commented Oct 20, 2011 at 13:27
  • Manuel set me off on the right direction , it was submitting too many parameters from what I can tell. By adding $(this.theExtraInput).remove(); to the cleanSource function of widgEditor it now only submits the content field and works fine. Thanks for the help! – Jeff_Hd Commented Oct 20, 2011 at 13:48
Add a comment  | 

2 Answers 2

Reset to default 23

for others who met the same problem:

this error is caused when you have two fields in your form like:

video: 'some string'
video['url']:  'some url'

then rails will crash with the error: expected Hash (got String) for param

the solution is quite simple: change 'video' to something else. e.g.:

video_origin_url: 'some string'
video['url']: 'some url'

see this question also: https://stackoverflow.com/a/19246703/445908

Turns out it was submitting too many parameters from what I can tell. By adding $(this.theExtraInput).remove(); to the cleanSource function of widgEditor it now only submits the content field and works fine.

发布评论

评论列表(0)

  1. 暂无评论