Kohana 3 ORM. How to set up Inflector irregular word arrays in the Bootstrap or Model - orm

I am using Kohana 3 ORM and it seems that the Inflector is singularising the word 'causes' to the form 'caus' instead of 'cause'. I have a _has_many_"through" relationship setup and even through all my foreign keys are setup to read 'cause_id' it still wants to setup an ON clause in SQL where it references 'caus_id' rather than 'cause_id'.
Is there a way to set up the Cause model to recognise the default singular form is 'cause'?
Or is there a way to add an Inflector->irregular array in the Bootstrap.php file?
I've hacked the SYSPATH.'config/inflector.php' file adding the exception and it does fix the problem but I would prefer a method that doesn't involve hacking the system files.
What is the 'best practice' approach please.

Copy SYSPATH/config/inflector.php to APPPATH/config/inflector.php and change what you want. This will allow you to upgrade framework core without loosing your modifications.
Post an issue and this will be fixed in the next release.

Related

How to implement merge conflict preview using libgit2?

I'm trying to implement a content management website, in many ways, it's like a simplified github.
the version control and collaboration part is based on git using libgit2.
But I can't find how to implement merge conflict preview, that would tell an user if her change is clean to merge or not and which lines have conflict.
the example here https://github.com/libgit2/libgit2/blob/master/examples/merge.c
performs merging with the git_merge function, however, this function would directly alter the current index.
I also checked a github open source alternative, but I forgot its name now. That project used a library from the eclipse ide, which provides a conflict preview feature.
How should I implement this with libgit2 and is there an example code?
As you noted, the git_merge function mutates the working directory and the index. You can use the git_merge_commits function to do an in-memory merge of two commits and return the resulting index.
You can then iterate over the index looking for conflicts or simply call git_index_has_conflicts if you only want to know if conflicts exist.

Grails 3 - achieving customization of template in a way it was possible with _form.gsp in version 2

I am relatively new to Grails and I am little disappointed with the way _form.gsp removed with field plugin in Grails 3. _form.gsp seemed to be good time saving option when we need to customize views with Bootsrap or materialize.
Now with grails 3, install-templates does not create _form.gsp. As per this documentation, we can achieve customization by creating _wrapper.gsp, _widget.gsp etc under view/_fields/default directory. But I am not able to find the example of such custom GSPs.
Also, let's say if I customize all the four GSPs (_wrapper.gsp, _widget.gsp, _displayWrapper.gsp, _displayWidget.gsp) will it generate actual code when we run generate-view command? I mean will it replace, f:all, f:table etc tag with actual code? If not then there is quite amount of work to do I guess. Because after we are confident about our domain class and tested all CRUD operation, we run generate-view command for creating all the domain specific GSPs. Then in most cases, we need to do some changes according to our requirement, like re-ordering the fields, hiding some of the fields
So in conclusion I have two goals:
Customizing default templates and start developing.
When I run generate-view, I do not want f:all, f:table etc abstract tags. I need actual fields in place so that I can customize generated views of domain.
If any one has achieved this, then please share the solution.
Grails 3 comes with the fields plugin by default. The templates used in Grails 2.x have been replaced in full. So, your goal 2. will be hard to achieve with Grails 3 it seems.
However, here is a helpful blog which explains how you can adjust some of the fields templates by replacing them in your project: http://blog.anorakgirl.co.uk/2016/01/what-the-f-is-ftable/
Similar to the description provided, you can place a modified _list.gsp template in folder in
/grails-app/views/templates/_fields/
Hope it helps.

Workflow for modifying existing crud scaffolded model, views & controllers

I am in the process of learning Yii framework. I have always previously built plugins in wordpress and I have never used a PHP MVC framework before.
Assuming I have designed my database
Used Yiic shell - console to model the db and create crud classes etc.
Modified the controllers and views to my custom requirements.
Now the client requirements change and an extra field is required in the database.
I modify the database to add for example "tel2" field to the customer table.
Do I need to update the model, view and controller manually to incorporate these changes or do I save customisations then get Yiic shell to re-scaffold the model, view & controller, then re-write the customisations manually?
I am sure that I can do either, but is there an easier way / is there a way in which you all work which makes your lives easier?
This was a question on my mind also when I began Yii.
The simple answer to it is you dont have to change everything. The Gii module is a really powerful feature of Yii and after making the CRUD and the model after a DB table, and if you have your own custom functions and methods and then you decide that you need to alter a table and add a new column to it, all you need to do remake the model in gii and it shall show the the modified code in a seperate link tagged as "diff".
Gii only generates the code, it does not overwrite it.
Now all you need to do is open up the "diff" make sure that you do not overwrite the code as there would be an overwrite button as well. After you check out the "diff" code, it shall show the new columns and the new properties highlighted, now all you need to do is copy the requisite changed code into your original code.
This way, you can do as many changes as you want with everything remaining intact.
There is also another method. You can use a base class and extend all your code into another file. This way, all you need to do is change the base model and everything still remains intact.
I think this should have answered your question.
Regards,
You should look at gii as a tool that gets you started quickly. But once you created your models and maybe CRUDs you can usually forget about it. Your project code evolves and - if it's not a very simply project - you will have a lot of manual changes to the auto generated code anyway.
So every time you touch your DB you will update the related files. Often this only involves to add a new attribute rule in rules() in your model, and adding another input field to the form view.

Core Data: Entity modified

I'm new to Core Data and I can't find the answer into the docs (but I'm sure it's somewhere):
I defined the properties for my entities and test my third version of an application (ASOC, ObjC, ObjC+CoreData): I write, read, create and remove objects, undo/redo actions, autosave, and everything is working like a charm for the moment (Stefan, my old dictionaries are gone and replaced by… well… managed objects I suppose )
I'm saving my file in binary format. The images, icons, rtfd texts are"Transformed"-type properties, because binding images by data is a deprecated manner which issues a warning (once).
Now: what if I decide to ADD a property to an entity? The previous files become unreadable! The app issues an alert:
The document “xxx” could not be opened. The file isn’t in the correct
format
I suppose Apple has implemented a sort of "backward compatibility", as the file is archived with keys/properties: when I archived some dictionaries, I could add or remove keys without problems…
Any link welcome!
If i understood you right, you changed your Core Data Model and want to use it with the binary store you used before. If it's the issue, you need to make a Core Data Migration, the whole process of which is described here.
http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CoreDataVersioning/Articles/Introduction.html

Cleanup Transfer ORM definitions?

Started researching Transfer ORM recently and find it pretty cool.
Today I've noticed that definitions directory contains some old files from my previous development sessions (ex. 27/08, 28/08). I have only few objects in transfer.xml for that project, but they produced few definition files each already.
Should I worry about them?
Maybe the only reason is that object XML changes, so it's development-only issue.
Will Transfer cleanup these after some period or I should set up the script to do this? If second way, which algorithm would you recommend to avoid removing files in use? Simply remove all of them when going live?
Thanks.
I don't believe Transfer deletes old files that it generates. They are safe to delete using any method as they will regenerate the first time they are needed.