"Undefined method"

I have a controller named RegistriesController. It contains a single
method:

def edit
@jolts_registry = JoltsRegistry.new
end

This runs, and the associated view is invoked. That stops on line 9:

<%= form_for @jolts_registry do |f| %>

The message is:

undefined method `jolts_registries_path’ for
#<#Class:0x184fdd4:0x1cf7aa0>

What does that mean?


Tim S.
[email protected]

On Aug 21, 2012, at 4:12 PM, Tim S. wrote:

The message is:

undefined method `jolts_registries_path’ for
#<#Class:0x184fdd4:0x1cf7aa0>

It means you haven’t set up a route for it in routes.rb, but you’re
using one of the route helpers in your view anyway. But have you
inspected what this named class is? Is it an instance of your
JoltsRegistry model, or maybe nil?

Walter

On 21 August 2012 21:12, Tim S. [email protected] wrote:

The message is:

undefined method `jolts_registries_path’ for
#<#Class:0x184fdd4:0x1cf7aa0>

What does that mean?

Have you put an entry for jolts_registries in routes.rb? Probably
something like
resources :jolts_registries

form_for needs the route to generate the form tag.

Colin

Colin L. [email protected] wrote:

<%= form_for @jolts_registry do |f| %>
resources :jolts_registries
I have

match ‘/registries’ => 'registries#edit;

It clearly finds the route, otherwise it wouldn’t run the edit method
in registries_controller.

form_for needs the route to generate the form tag.

Don’t understand, which route?


Tim S.
[email protected]

On 22 August 2012 13:47, Tim S. [email protected] wrote:

This runs, and the associated view is invoked. That stops on line 9:
Have you put an entry for jolts_registries in routes.rb? Probably
something like
resources :jolts_registries

I have

match ‘/registries’ => 'registries#edit;

It clearly finds the route, otherwise it wouldn’t run the edit method
in registries_controller.

It is not that route that is the problem

form_for needs the route to generate the form tag.

Don’t understand, which route?

You are trying to create a form for a JoltRegistry, that expects to
submit to a jolts_registries_path (as in the error message). The
normal way to generate the route would be to use
resources :jolts_registries

Have a look at the Rails Guide on Routing if you don’t know what that
does.

Colin

Colin L. [email protected] wrote:

Don’t understand, which route?

You are trying to create a form for a JoltRegistry, that expects to
submit to a jolts_registries_path (as in the error message). The
normal way to generate the route would be to use
resources :jolts_registries

I’ve done that. Same message. I’ve tried several different
permutations of methods, etc. Always the exact same message. I have no
clue in the world what in the hell it wants me to do. I have no clue
where it gets “jolts_registries” from in the first place.


Tim S.
[email protected]

Tim S. [email protected] wrote:

I’ve done that. Same message. I’ve tried several different
permutations of methods, etc. Always the exact same message. I have no
clue in the world what in the hell it wants me to do. I have no clue
where it gets “jolts_registries” from in the first place.

Changing the form tag from

<%= form_for @registry do |f| %>

to

<%= form_for @registry, :url => { :action => “create” } do |f| %>

fixed it.


Tim S.
[email protected]

On 22 August 2012 17:38, Tim S. [email protected] wrote:

I’ve done that. Same message. I’ve tried several different
permutations of methods, etc. Always the exact same message. I have no
clue in the world what in the hell it wants me to do. I have no clue
where it gets “jolts_registries” from in the first place.

In your first post you had
@jolts_registry = JoltsRegistry.new
so @jolts_registry is of JoltsRegistry and hence the route it is looking
for.

Did you restart the server after changing routes.rb? That is one of
the few times it is necessary to restart it.
If it is still not working post your routes.rb file, the output from
rake routes
and copy and paste the error message and the section of code it relates
to.

Did you read and understand the guide on routing?

Colin

On 22 August 2012 21:08, Tim S. [email protected] wrote:

resources :jolts_registries

I’ve done that. Same message. I’ve tried several different
permutations of methods, etc. Always the exact same message. I have no
clue in the world what in the hell it wants me to do. I have no clue
where it gets “jolts_registries” from in the first place.

Changing the form tag from

<%= form_for @registry do |f| %>

It was not that in the first place, according to your post it was
<%= form_for @jolts_registry do |f| %>

Colin

On Thu, Aug 23, 2012 at 6:17 PM, Tim S. [email protected]
wrote:

Colin L. [email protected] wrote:

It was not that in the first place, according to your post it was
<%= form_for @jolts_registry do |f| %>

ah…Right. I tried a good many things, kept getting the exact same
error until putting the “action” phrase in. yes I looked at the
routing doc. Didn’t see anything to help. Still don’t get it.

It would be more helpful for the people if you post your routes.rb here.


Azhagu Selvan

http://tamizhgeek.in

Colin L. [email protected] wrote:

It was not that in the first place, according to your post it was
<%= form_for @jolts_registry do |f| %>

ah…Right. I tried a good many things, kept getting the exact same
error until putting the “action” phrase in. yes I looked at the
routing doc. Didn’t see anything to help. Still don’t get it.


Tim S.
[email protected]