On Fri, Nov 28, 2008 at 11:09 PM, Jonathan Conway <[EMAIL PROTECTED]> wrote:

> Hi Guys,I'm currently upgrading a merb app from 0.9.7 to 1.0.3 and
> whenever I try and start the app up or run a rake task I
> receive an error if I have a controller who has the same plural name as an
> existing model e.g comments.rb (controller) and it's associated model
> comment.rb (model).
>
> The error looks like the following:
>
> "You tried to define resource on Comments but it was already defined on
> Merb::Controller. If you meant to override a core method, use override!"
>
> Has anyone else come across this problem?
>
> Cheers
>
> Jonathan
>

Hi Johnathan,

This is a new feature in merb 1.0.3 controllers where if you try to
overwrite a core method (ie the merb framework) then an exception will be
raised.  I'm assuming that you're defining a def resource method.  This is
to prevent unintentional behavior.

The method you're clashing with here will be the resource method which is
used to generate urls for "resources"  eg.

resource(@post) #=> /posts/3

If you really want to over ride the method you can call the override! method
before declaring it.

eg

override! :resource
def resource
  # your decleration here
end

However, it's there to help you identify that you're overwriting a part of
the framework.   Like most things in merb though... you can overwrite it ;)

Cheers
Daniel


>
>
>
>
> --
> ---------------------
> www.jaikoo.com
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to