简体   繁体   中英

form_for not working for Acta model

I have two models: User , and Acta , two controllers: UsersController and ActasController , etc.

The following works in a template:

<%= form_for User.new do |f| %>
<% end %>

while the following fails:

<%= form_for Acta.new do |f| %>
<% end %>

The error shown is:

Showing /Users/gdiazc/workspace-rails/rev_dem/app/views/actas/_form.html.erb where line #1 raised:
undefined method `acta_index_path' for #<#<Class:0x007fc4a609b678>:0x007fc4a74026a8>

I suspect this might have something to do with pluralization, as acta_index_path sounds strangely pluralized. I then added the following code to config/environment.rb :

ActiveSupport::Inflector.inflections do |inflect|
  inflect.irregular 'acta', 'actas'
end

With no change. Any help? (Rails 4.1.4)

I think the same problem is here StackOverflow

I try in console 'acta'.pluralize => 'acta'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM