Search code examples
ruby-on-railscontrollerargumentsargument-error

ArgumentError in Rails


I want to connect two entity (project and issues) and Rails says some error message, but I don't know, what should I do. Can you help me fix it, please? Thanks a lot.

Error screen


Solution

  • Not sure what your are trying to do, but it looks like you have a nested resource and therefore want to pass an array to form_for, but you are actually passing two separate objects. Change:

    <%= form_for(@project, @project.issues.build) do |f| %>
    

    to:

    <%= form_for([@project, @project.issues.build]) do |f| %>
    

    With this change you'll pass one array for form_for, instead of two arguments.