Monday, September 27, 2010

Re: Big problems trying to use "medium" as a model name

I didn't change anything in the source, and it worked under v1.2.0.x,
and now it doesn't anymore. So I presume it's because of the upgrade
to v1.3.4, and I also found this:

"Adding media as an uninflected word" on https://trac.cakephp.org/changeset/5104

Anyone could try to bake a small application with a Medium/Media model
that has a HABTM relationship to an Author/Authors model? As far as I
can see this is NOT possible for some reason... And don't forget to
add the inflection rule:

Inflector::rules('plural', array('rules' => array(), 'irregular' =>
array('medium' => 'media'), 'uninflected' => array()));

On Fri, Sep 24, 2010 at 7:54 PM, cricket <zijn.digital@gmail.com> wrote:
> On Fri, Sep 24, 2010 at 5:52 AM, psybear83 <psybear83@gmail.com> wrote:
>> Hi everybody
>>
>> I have upgraded a CakePHP application from 1.2.0.x to 1.3, and
>> everything works quite fine now, except one thing.
>>
>> I have a "Medium" model (which will hold data of books, DVD's,
>> newspapers etc.), which has a HABTM relationship to an "Author" model.
>> In version 1.2. this was no problem, but after upgrading I had several
>> problems.
>>
>> First of all, the plural form "media" was not singularized to the form
>> "medium" anymore, while the other way "medium" became "media". Doesn't
>> make too much sense in my opinion, does it? So I added the following
>> Inflector exception:
>>
>> Inflector::rules('plural', array('rules' => array(), 'irregular' =>
>> array('medium' => 'media'), 'uninflected' => array()));
>>
>> Now it works as expected:
>>
>> singularize('media') => medium
>> pluralize('medium') => media
>>
>> But sadly I'm still having troubles, because eveytime I try to add/
>> edit a medium or an author, I'm getting the following error:
>>
>> Notice (8): Undefined index:  id [CORE/cake/libs/model/model.php, line
>> 1391]
>> Model::__saveMulti() - CORE/cake/libs/model/model.php, line 1391
>> Model::save() - CORE/cake/libs/model/model.php, line 1355
>> Scaffold::__scaffoldSave() - CORE/cake/libs/controller/scaffold.php,
>> line 322
>> Scaffold::__scaffold() - CORE/cake/libs/controller/scaffold.php, line
>> 479
>> Scaffold::__construct() - CORE/cake/libs/controller/scaffold.php, line
>> 202
>> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 194
>> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 171
>> [main] - APP/webroot/index.php, line 83
>>
>> It looks to me like there's still somewhere a problem with the medium/
>> media singularization/pluralization?
>>
>> So my question: can this be fixed somehow, or is "Medium" just no
>> suitable name for a model? I'd rather not want to change the name,
>> because there is quite some code already that depends on this name...
>> Maybe I have to use another inflection rule or something?
>>
>> Thanks a lot for help, I'm working since many hours on this and now
>> I'm really stuck.
>> Josh
>
> Why do you presume the two issues are related? Are you certain your
> model associations are correct?
>
> Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: