<%= form_for @video, :html => {:multipart => true} do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.file_field :translation_handwritten %>
</p>
<p><%= f.submit %></p>
<% end %>
有沒有人有任何想法,爲什麼這可能會引發這樣的錯誤?我很迷路... 錯誤的參數數量(2 for 1)Rails form_for
這是我的應用程序的Gemfile。這些可能的罪魁禍首是?我需要改變什麼? 源 'https://rubygems.org'
gem 'rails', '3.2.14'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sass-rails', '~> 3.2.3'
gem 'bootstrap-sass'
gem 'bcrypt-ruby', '3.0.1'
gem 'devise'
gem 'omniauth-google-oauth2'
gem 'omniauth-facebook'
gem 'whenever', :require => false
gem 'carrierwave' #see README: https://github.com/carrierwaveuploader/carrierwave
group :development, :test do
gem 'sqlite3'
gem 'pg'
gem 'rails_12factor'
gem 'ruby-debug19'
gem 'database_cleaner'
gem 'capybara'
gem 'launchy'
gem 'rspec-rails'
gem 'simplecov'
gem 'factory_girl_rails'
gem 'ffaker'
gem 'whenever'
end
group :test do
gem 'cucumber-rails', :require => false
gem 'cucumber-rails-training-wheels'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :assets do
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'haml'
UPDATE 當我改變@video任何其他型號我有,它沒有錯誤。 (它顯然無法正常工作,因爲我需要將它附加到視頻中)。什麼可能導致這個?
require 'carrierwave/orm/activerecord'
class Video < ActiveRecord::Base
attr_accessible :course, :qa_complete, :qa_id, :subject, :title,
:translate_complete, :translator_id, :type_complete, :typer_id, :video_id, :due_date, :translation_handwritten
validates :video_id, :presence => true, :uniqueness => true #add uniqueness in db too
mount_uploader :translation_handwritten, TranslationsUploader
end
更新2這裏是我的應用程序跟蹤:
app/views/shared/_form.html.erb:1:in `_app_views_shared__form_html_erb___611020419_98374470'
app/views/videos/translate_video_handwritten.html.haml:54:in `_app_views_videos_translate_video_handwritten_html_haml__702424599_100568110'
您可能有一個覆蓋'form_for'的默認行爲的gem /庫。你可以發佈你的Gemfile嗎? – zeantsoi
在http://stackoverflow.com/questions/16278247/form-for-wrong-number-of-arguments-in-rails-4常見的罪魁禍首是meta_search和client_side_validations –