Wrong number of arguments error (0 for 1)

I have a form in index.erb.html file. (boot controller). When I call localhost: 3000 / upload / I get wrong number of arguments error (0 for 1) error

    <% form_for :picture, :html => { :multipart => true } do |form| %>
 <p>
    <label for="picture_first_name">First name::</label>
    <%= form.text_field :first_name, :size => 20 %>
 </p>
 <p>
    <label for="picture_last_name">Last name:</label>
    <%= form.text_field :last_name, :size => 20 %>
 </p>
 <p>
    <label for="picture_city">City:</label>
    <%= form.select :city, Picture::CITIES, {}, :onchange => remote_function(:url => {:action => "update_universities"}, :with => "'picture[city]='+value") %>
 </p>
 <p>
    <%= render :partial => 'universities' %>
 </p>
 <p>
    <label for="picture_picture">Photo::</label>
    <%= form.file_field :picture, :size => 20 %>
 </p>
 <%= submit_tag "Upload" %>
<% end %>

      

So I have a render function because I am using AJAX to update the second select box.

   <label for="picture_university">University:</label>
    <%= form.select :university, [] %>

      

What is the problem with my application? Please help me fix this!

ArgumentError in Upload # index

App / views / downloads / _universities.html.erb are shown where line # 2 is raised:

wrong number of arguments (0 for 1)

Extracted source (around line # 2):

1: University: 2: <% = form.select: university, []%>

Tracking template inclusion: app / views / downloads / index.html.erb

RAILS_ROOT: / home / user_admin / myapp Application Trace | Frame track | Full trace

/home/user_admin/myapp/app/views/upload/_universities.html.erb:2:in form' /home/user_admin/myapp/app/views/upload/_universities.html.erb:2:in

_run_erb_app47views47upload47_universities46html46erb_locals_object_universities' / home / user _admin / myapp / app / views / upload / index.html.rb: _run_erb_app47views47upload47index46html46erb' /home/user_admin/myapp/app/views/upload/index.html.erb:1:in

15app / views / upload / index.html.erb: 15

+2


source to share


1 answer


You need to pass the variable form

before the partial, so:

<%= render :partial => 'universities', :locals => {:form => form } %>

      



this should make the form object available to your partial.

+2


source







All Articles