ruby on rails - Where is undefined method called? -
i have decisions
resource, nested under groups
resource. has_many
, belongs_to
have been defined in models.
resources :groups resources :decisions end
...and have edit form @ path:
/groups/:group_id/decisions/:id/edit(.:format)
i'm getting error in rspec test:
failure/error: put :update, {:id => decision.to_param, :decision => valid_attributes, group_id: decision.group.id}, valid_session nomethoderror: undefined method `decision_url' #decisionscontroller:0x007ffeb23482e0>
and when navigate form in development environment, similar error:
<%= link_to 'edit', edit_group_decision_path(@group, @decision) %>
nomethoderror @ /groups/6/decisions/5/edit
undefined method `decision_path' #<#:0x007fd1ff569130>
i'm using 'better_errors'
gem, , cites first line of form_for
no method error:
<%= form_for(@decision) |f| %>
i don't have 'decision_url'
anywhere in code. missing? shouldn't form_for
know put update? there's valid path at:
/groups/:group_id/decisions/:id(.:format)
here part of log looks exciting:
rendered decisions/_form.html.erb (6.5ms) rendered decisions/edit.html.erb within layouts/application (7.1ms) completed 500 internal server error in 9ms (activerecord: 0.1ms) nomethoderror - undefined method `decision_path' #<#<class:0x007fd5d98527b0>:0x007fd5d400d618>: actionpack (4.2.3) lib/action_dispatch/routing/polymorphic_routes.rb:220:in `polymorphic_method' actionpack (4.2.3) lib/action_dispatch/routing/polymorphic_routes.rb:134:in `polymorphic_path' actionview (4.2.3) lib/action_view/helpers/form_helper.rb:466:in `apply_form_for_options!' actionview (4.2.3) lib/action_view/helpers/form_helper.rb:434:in `form_for'
you've specified nested resources this:
resource groups resource decisions end
the routing, however, should specified using symbols, this:
resource :groups resource :decisions end
make sure models have proper relationships defined:
class group < activerecord::base has_many :decisions end class decision < activerecord::base belongs_to :group end
Comments
Post a Comment