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 %>

  <p>     <%= f.label :name %><br />     <%= f.text_field :name %>   </p>   <p>     <%= f.label :owner %><br />     <%= f.text_field :owner %>   </p>   <p>     <%= f.label :private %><br />     <%= f.check_box :private %>   </p>   <p>     <%= f.submit 'Update' %>   </p> <% end %>

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

Thanks,

jakx12.

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 Troutwine wrote in post #964363:

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 Haagmans wrote in post #964371:

so try changing it to :

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

(assuming your controller is call "RepositoriesController" rather than "RepositoryController"

Michael Pavling wrote in post #964379:

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 Pavling wrote in post #964384:

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

Zack Nathan 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,

Michael Pavling wrote in post #964391:

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: www.xxxx.com/repository/1/bugs/1. 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, Zoltán

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.

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

Colin

Colin Law wrote in post #964458:

I Like to order ugg boots,they are 100% original, and they are very cheap and good secvice, Non Tax,Free Shipping. if you like it,you can buy it from this company. www uggscom com really?