2013-12-11 72 views
0

現在我正在嘗試設置ajax form_tag。我寫了下面的代碼,但得到周圍ArgumentError在/成員/ 18個錯誤數量的參數(3爲2)

<%= text_field_tag 'name' %> 

☆錯誤消息

ArgumentError at /members/18 
wrong number of arguments (3 for 2) 

你能告訴我如何修改我的代碼的錯誤信息?

☆show.html.erb(成員)

<h4 class="title">ユーザーの投稿</h4> 
     ※同じ本を読んでいる全ユーザーの投稿が表示されます。<br/> 
      <div class= "form_index"> 
      <%= form_tag({:action=>"show"}, {:method =>"get"}, {:remote=>true}) do %> 
      <div class="from_field_index"> 
      <%= text_field_tag 'name' %> 
      <%= submit_tag '本検索' %> 
      <% end %> 
      </div> 
     </div> 

     <div class= "form"> 
      <%= form_tag({:action=>"show"}, {:method =>"get"}, {:remote=>true}) do %> 
      <div class="from_field_index"> 
      <%= text_field_tag 'content' %> 
      <%= submit_tag '文検索' %> 
      <% end %> 
      </div> 
     </div> 

    <div id="show"></div> 

☆members_controller

@gmsg_users = GroupMessage.where(:group_id => join_groups).order("created_at desc").limit(15) 
     @gmsg_users.scoped 
     if params[:name].present? 
     @gmsg_users = @gmsg_users.where("name like ?" , "%" + params[:name] + "%") 
     end 
     if params[:content].present? 
     @gmsg_users = @gmsg_users.where("name like ?" , "%" + params[:content] + "%") 
     end 

☆show.js.erb

$('#show').html(
      "<%= escape_javascript(render :partial => 'search_result')%>" 
      ); 

☆_search_result.html.erb

<div class="message_area"> 
       <% @gmsg_users.each do |gmsg| %> 
       <div class="each_message"> 
        <a href="/groups/<%= gmsg.group.id%>" ><%= image_tag gmsg.group.imageurl,:width => '20', :height => '25' %><%= "(" + gmsg.group.name + ")" %></a> 
        <%= 'Page:' + gmsg.page.to_s + '&' %><%= 'Line:' + gmsg.line.to_s %> 
        <a href="/members/<%= gmsg.member.id%>"><%= gmsg.member.name %></a> 
        (<%= gmsg.created_at.strftime'%Y-%m-%d %H:%M' %>) 
       <div class="group_message"> 
        <p class="message_content"><a href="/group_messages/<%= gmsg.id%>" > <%= truncate(gmsg.content, { :length => 50}) %></a></p> 
       </div><!--group_message--> 
       <br/> 
        <% if gmsg.group_message_comments.present? %> 
        <% gmsg.group_message_comments.each do |gmsc|%> 
         <div class="group_message_comment"> 
         <p><a href="/members/<%= gmsc.member ? gmsc.member.id : "unknown" %>"><%= gmsc.member ? gmsc.member.name : "unknown" %></a> (<%= gmsc.created_at.strftime'%Y-%m-%d %H:%M' %>)</p> 
         <%= gmsc.content %> 
         <br/> 
         </div> <!--group_message_comment--> 
        <% end %><!-- each do -- > 
        <% end %> <!--if --> 
       </div><!--each_message--> 
       <br/> 
       <% end %> <!--each do --> 
      </div> <!--message_area--> 

回答

相關問題