I have a NoMethodError, please help!

Hey everyone,

I get this error for some reason when trying to access my new action.
Here’s the error:
undefined method `repositories_path’ for #ActionView::Base:0x1034c7648

Heres my view code:

<% form_for(@repository) do |f| %>
<%= f.error_messages %>

<%= f.label :name %>
<%= f.text_field :name %>

<%= f.label :owner %>
<%= f.text_field :owner %>

<%= f.label :private %>
<%= f.check_box :private %>

<%= f.submit 'Update' %>

<% end %>

My repository controller is a resources in routes. Whats wrong?!

Thanks,

jakx12.

On Sat, Nov 27, 2010 at 3:43 PM, Zack N. [email protected]
wrote:

Hey everyone,

I get this error for some reason when trying to access my new action.
Here’s the error:
undefined method `repositories_path’ for #ActionView::Base:0x1034c7648

Heres my view code:

<% form_for(@repository) do |f| %>

It is expected by your view that the controller serving up this view
has defined a model instance @repository.

Brian T. wrote in post #964363:

On Sat, Nov 27, 2010 at 3:43 PM, Zack N. [email protected]
wrote:

Hey everyone,

I get this error for some reason when trying to access my new action.
Here’s the error:
undefined method `repositories_path’ for #ActionView::Base:0x1034c7648

Heres my view code:

<% form_for(@repository) do |f| %>

It is expected by your view that the controller serving up this view
has defined a model instance @repository.

Thanks for the reply. I do have an instance, it says: @repository =
Repository.new

On Nov 27, 10:50pm, Michael P. [email protected] wrote:

On 27 November 2010 21:17, Brian T. [email protected] wrote:

undefined method `repositories_path’ for #ActionView::Base:0x1034c7648

It is expected by your view that the controller serving up this view
has defined a model instance @repository.

More likely (due to the “repositories path”) to be a routing problem.
Zack, do you have “map.resources :repositories” in your routes.rb
file?

Or, if you’re on Rails 3.0 “resources :repositories”

Jaap H. wrote in post #964371:

On Nov 27, 10:50pm, Michael P. [email protected] wrote:

On 27 November 2010 21:17, Brian T. [email protected] wrote:

undefined method `repositories_path’ for #ActionView::Base:0x1034c7648

It is expected by your view that the controller serving up this view
has defined a model instance @repository.

More likely (due to the “repositories path”) to be a routing problem.
Zack, do you have “map.resources :repositories” in your routes.rb
file?

Or, if you’re on Rails 3.0 “resources :repositories”

I dont actually. My routes for repository looks like this: map.resources
:repository, :has_many => :bugs

On 27 November 2010 22:10, Zack N. [email protected] wrote:

More likely (due to the “repositories path”) to be a routing problem.
Zack, do you have “map.resources :repositories” in your routes.rb
file?

I dont actually. My routes for repository looks like this: map.resources
:repository, :has_many => :bugs

so try changing it to :

map.resources :repositories, :has_many => :bugs

(assuming your controller is call “RepositoriesController” rather than
“RepositoryController”

Michael P. wrote in post #964379:

On 27 November 2010 22:10, Zack N. [email protected] wrote:

More likely (due to the “repositories path”) to be a routing problem.
Zack, do you have “map.resources :repositories” in your routes.rb
file?

I dont actually. My routes for repository looks like this: map.resources
:repository, :has_many => :bugs

so try changing it to :

map.resources :repositories, :has_many => :bugs

(assuming your controller is call “RepositoriesController” rather than
“RepositoryController”

my controller is called RepositoriesController. I just dont see where
the problem is! Its super strange…

On 27 November 2010 22:37, Zack N. [email protected] wrote:

I just dont see where the problem is! Its super strange…

For the last time… have you done this?

so try changing it to :

map.resources :repositories, :has_many => :bugs

You might notice, that your current route mapping is singular, and the
one I’ve suggested using is plural…

Michael P. wrote in post #964384:

On 27 November 2010 22:37, Zack N. [email protected] wrote:

I just dont see where the problem is! Its super strange…

For the last time… have you done this?

so try changing it to :

map.resources :repositories, :has_many => :bugs

You might notice, that your current route mapping is singular, and the
one I’ve suggested using is plural…

But does that work with a singular named controller?
Thanks,

jakx12

Zack N. wrote in post #964388:
[…]

You might notice, that your current route mapping is singular, and the
one I’ve suggested using is plural…

But does that work with a singular named controller?

Why do you want a singular-named controller? Plural is the usual
convention, unless you have a singular resource (in which case you need
“resource”, not “resources”, in your routes file).

Learn the Rails conventions and understand them before you try to break
them.

Thanks,

jakx12

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

On 27 November 2010 21:17, Brian T. [email protected] wrote:

undefined method `repositories_path’ for #ActionView::Base:0x1034c7648

It is expected by your view that the controller serving up this view
has defined a model instance @repository.

More likely (due to the “repositories path”) to be a routing problem.
Zack, do you have “map.resources :repositories” in your routes.rb
file?

On 27 November 2010 23:24, Zack N. [email protected] wrote:

You might notice, that your current route mapping is singular, and the
one I’ve suggested using is plural…

But does that work with a singular named controller?
Thanks,

You don’t have a singular named controller… and if you did why
would you be mapping resources for it?

Michael P. wrote in post #964391:

On 27 November 2010 23:24, Zack N. [email protected] wrote:

You might notice, that your current route mapping is singular, and the
one I’ve suggested using is plural…

But does that work with a singular named controller?
Thanks,

You don’t have a singular named controller… and if you did why
would you be mapping resources for it?

My controller is named repository. I have the resource named repository
because then I can have url like this: XXXX.
Is this wrong?

Thanks,

jakx12.

On 27 November 2010 23:46, Zack N. [email protected] wrote:

You don’t have a singular named controller… and if you did why
would you be mapping resources for it?

My controller is named repository.

you said earlier:

my controller is called RepositoriesController.

…now you’re saying is actually RepositoryController?

I have the resource named repository
because then I can have url like this: XXXX.
Is this wrong?

Yes… Marnen’s post covers this too - the Rails convention is:
www.xxxx.com/repositories/1/bugs/1

Hello,
I read the whole mailing, and not sure if I agree.

So first this problem means you don’t have the method in the
Controller. I agree, controllers have naming conventions, check those.
Also routes.rb has conventions, depends on version - which do you use?

If you’ve written your route to the file, you can check if it’s
available from command line:
rake routes
Here you will see the url path and the pathname also, so will be
visible if you gave it wrong.

Which versions do you use? Did you scaffolded or created part by part?
cheers,
Zoltn

Zoltan Gero wrote in post #964442:

Hello,
I read the whole mailing, and not sure if I agree.

So first this problem means you don’t have the method in the
Controller. I agree, controllers have naming conventions, check those.
Also routes.rb has conventions, depends on version - which do you use?

If you’ve written your route to the file, you can check if it’s
available from command line:
rake routes
Here you will see the url path and the pathname also, so will be
visible if you gave it wrong.

Which versions do you use? Did you scaffolded or created part by part?
cheers,
Zoltn

I scaffolded it. Im using rails 2.3.8. Sorry I meant that my controller
is named singularly. So do you guys think I should pluralize it?

Thanks,

jakx12.

On 28 November 2010 12:31, Zack N. [email protected] wrote:

[…]
I scaffolded it. Im using rails 2.3.8. Sorry I meant that my controller
is named singularly. So do you guys think I should pluralize it?

Model should be Repository in repository.rb
Controller should be RepositoriesController in
repositories_controller.rb

Colin

Colin L. wrote in post #964458:

On 28 November 2010 12:31, Zack N. [email protected] wrote:

[…]
I scaffolded it. Im using rails 2.3.8. Sorry I meant that my controller
is named singularly. So do you guys think I should pluralize it?

Model should be Repository in repository.rb
Controller should be RepositoriesController in
repositories_controller.rb

Colin

alrighty, thanks!