Error : ArgumentError in Messages#new wrong number of arguments (2 for 1)
<p>I m getting ArgumentError in Messages#new
app/views/messages/new.html.erb where line #16 raised:
 "wrong number of arguments (2 for 1)" 
It also says:</p>

<p>app/helpers/application_helper.rb:8:in <code>avatar_url'
app/helpers/messages_helper.rb:5:in</code>block in recipients_options'
app/helpers/messages_helper.rb:4:in <code>recipients_options'
app/views/messages/new.html.erb:16:in</code>block in _app_views_messages_new_html_erb___264831154_80406348'
app/views/messages/new.html.erb:3:in `_app_views_messages_new_html_erb___264831154_80406348'</p>

<p>My application helper:</p>

<pre><code>module ApplicationHelper

def page_header(text)
    content_for(:page_header) { text.to_s }
end


def avatar_url(user)
    if user.image
        user.image
    else
        "/images/missing.png"
    end
end
end
</code></pre>

<p>My messages helper is,</p>

<pre><code>module MessagesHelper


def recipients_options(chosen_recipient = nil)
    s = ''
    User.all.each do |user|
      s &lt;&lt; "&lt;option value='#{user.id}' data-img-src='#{image_tag avatar_url(user.email, size: 50)}' #{'selected' if user == chosen_recipient}&gt;#{user.name}&lt;/option&gt;"
    end
    s.html_safe
  end
end
</code></pre>

<p>my messages/new.html.erb is,</p>

<pre><code>&lt;% page_header "Start Conversation" %&gt;

&lt;%= form_tag messages_path, method: :post do %&gt;
  &lt;div class="form-group"&gt;
    &lt;%= label_tag 'message[subject]', 'Subject' %&gt;
    &lt;%= text_field_tag 'message[subject]', nil, class: 'form-control', required: true %&gt;
  &lt;/div&gt;

  &lt;div class="form-group"&gt;
    &lt;%= label_tag 'message[body]', 'Message' %&gt;
    &lt;%= text_area_tag 'message[body]', nil, cols: 3, class: 'form-control', required: true %&gt;
  &lt;/div&gt;

  &lt;div class="form-group"&gt;
    &lt;%= label_tag 'recipients', 'Choose recipients' %&gt;
    &lt;%= select_tag 'recipients', recipients_options(@chosen_recipient), multiple: true, class: 'form-control chosen-it' %&gt;
  &lt;/div&gt;

  &lt;%= submit_tag 'Send', class: 'btn btn-primary' %&gt;
&lt;% end %&gt;
</code></pre>

<p>messages_controller.rb</p>

<pre><code>class MessagesController &lt; ApplicationController


 before_action :authenticate_user!

  def new
    @chosen_recipient = User.find_by(id: params[:to].to_i) if params[:to]
  end

  def create
    recipients = User.where(id: params['recipients'])
    conversation = current_user.send_message(recipients, params[:message][:body], params[:message][:subject]).conversation
    flash[:success] = "Message has been sent!"
    redirect_to conversation_path(conversation)
  end
end
</code></pre>