# NoMethodError - previously defined method?

**URL:** <https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661>\
**Category:** Rails\
**Created:** [July 29, 2007, 3:10am UTC](https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661 "2007-07-29T03:10:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave\_Evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@Dave\_Evans](https://www.ruby-forum.com/u/Dave_Evans)\
**Post date:** [July 29, 2007, 3:10am UTC](https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661/1 "2007-07-29T03:10:29Z")

</div>

Hello,

I have a simple controller named AssociationsController. Here is a snip:

AssociationsController\< ApplicationController

def detail  
@association = Association.find(params[:id])  
render layout: =\> “frontend”  
end

def display  
@association = Association.find(params[:id])  
render layout: =\> “frontend”  
end

def displaydetail  
@association = Association.find(params[:id])  
render layout: =\> “frontend”  
end

end

When called using standard routing:  
[http://www.test.com/apps/public/associations/display/3](http://www.test.com/apps/public/associations/display/3)  
[http://www.test.com/apps/public/associations/detail/3](http://www.test.com/apps/public/associations/detail/3)  
[http://www.test.com/apps/public/associations/displaydetail/3](http://www.test.com/apps/public/associations/displaydetail/3)

Only the displaydetail method works, the others give:  
NoMethodError in Associations#display  
NoMethodError in Associations#detail

There are three identical rhtml files, each named for the method, as  
they should be.

Is this some sort of issue with display and detail already being  
defined elsewhere?

Thanks for any help you can give.

Dave

---

<div class="post-metadata">

**Author:** ![Dave\_Evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@Dave\_Evans](https://www.ruby-forum.com/u/Dave_Evans)\
**Post date:** [July 29, 2007, 3:37am UTC](https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661/2 "2007-07-29T03:37:31Z")

</div>

Hi Dave,

Dave Evans wrote:

> I have a simple controller named AssociationsController.  
> Here is a snip:
> 
> AssociationsController\< ApplicationController

Is your model, by any chance, names ‘associations’? If so, that’s  
probably  
where your problem starts.

hth,  
Bill

---

<div class="post-metadata">

**Author:** ![Dave\_Evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@Dave\_Evans](https://www.ruby-forum.com/u/Dave_Evans)\
**Post date:** [July 29, 2007, 3:59am UTC](https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661/3 "2007-07-29T03:59:33Z")

</div>

Nope, my model is named Association:

class Association \< ActiveRecord::Base

has\_many :bulletins  
file\_column :photo, :magick =\> { :geometry =\> “300x200\>” }

end

Why did you suspect that?

---

<div class="post-metadata">

**Author:** ![Dave\_Evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@Dave\_Evans](https://www.ruby-forum.com/u/Dave_Evans)\
**Post date:** [July 29, 2007, 5:29pm UTC](https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661/4 "2007-07-29T17:29:39Z")

</div>

Hi Dave,

Dave Evans wrote:

> Nope, my model is named Association:
> 
> Why did you suspect that?

Because Rails’ default behavior would lead one to expect  
AssociationController, not AssociationsController. I could be wrong,  
but I  
think that unless you tell it otherwise, Rails is going to look for a  
model  
named ‘Associations’. Try explicitly telling Rails what model to look  
for.

model :association

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![Dave\_Evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@Dave\_Evans](https://www.ruby-forum.com/u/Dave_Evans)\
**Post date:** [July 30, 2007, 2:29am UTC](https://www.ruby-forum.com/t/nomethoderror-previously-defined-method/110661/5 "2007-07-30T02:29:39Z")

</div>

That may be so. I used the generate script to generate scaffolding for  
the application. It created both an AssociationController and an  
AssociationsController.

If you have a look at the controller code I posted in my original  
email, you’ll see that I am specifying the Association model in my  
methods. The question is: Why do two methods that defined the same yet  
named differently behave differently? display doesn’t work.  
displaydetail does. That makes me think there is some previous  
definition of the display method that is taking precedence.

Dave
