Yang
Yang

Reputation: 9952

ruby on rails - wrong number of arguments (0 for 1) when using 'form'

Showing app/views/frontend/get_months.html.erb where line #1 raised:

wrong number of arguments (0 for 1)
Extracted source (around line #1):

1: <%= render :partial => "months", :locals => {:form => form} %>
RAILS_ROOT: /rails_workcopy/er_spending_report

My get_month.html.erb has only one line of code. if i use <%= form.select(...) %>, the error still occurs... anyone can show me how to use render partial function? Thanks in advance!

Upvotes: 0

Views: 1228

Answers (2)

StefanS
StefanS

Reputation: 876

According to http://api.rubyonrails.org/classes/ActionView/Partials.html your render partial syntax is correct.

If there's only one line in get_month.html.erb I would wonder from where you get the local variable "form" is coming from. Maybe it should be @form?

Also keep in mind that the partial you want to render needs to start with an underscore. So in your example you need a file _months.html.erb

Upvotes: 1

Steve
Steve

Reputation: 592

Try (assuming you're passing the form through a block in form_for:

<%= render 'months', :f => form %>

Any luck?

Upvotes: 0

Related Questions