Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Couch potato orm component #849
I tried out the couchrest thingie first but didn't like it as much as couch potato so I made the switch easily. And then I have tried to integrate the thing as a component also. The main stuff is there but I have some problem with the admin generators. If someone familiar with that code could have a look at my attempt I am sure it is only a matter of minutes before the couch potato support is there. My fork only contains these changes.
More specifically I am getting bad code in controllers/session.rb - the model_name is empty so a couple of methods are missing recievers.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Included in the commit is an attempt to simulate what should be needed by padring-admin. I added needed methods to the model for this purpose. It was a while ago now so I don't remember what went wrong but it certainly had to do with me not knowing enough about padrino-admin rather than it not being possible with couch_potato.
Yup @skade you're right, it's quite different but it shouldn't be that much of a trouble. Here's a git diff of @froderik's branch with a couple of patches to get it to work a bit further, it still misses those changes being applied in the controller and a few other places.
The repo is confusing, the author assumes methods like create on the readme that you won't find inside -there's even an issue asking where that method is and nobody answered. @froderik I also thought of adding those extra methods because it's great to consolidate the API with other ORMs but I reckon it's going against the ORM's design. In this case it would be better to create a gem or propose those changes to the library itself.
What do you think?
The reason why I'm asking is that this might also be a design flaw in padrino-admin. The thing we usually ended up with on small projects is just replacing the crucial lines in the admin controllers by their couch_potato equivalents. Its quickly done and painless.
padrino-admin fully relies on the fact that most database layers expose a uniform interface. It could possibly use an adapter pattern instead, with a default adapter for everything that behaves uniform and special adapters for couch_potato for example. Something like this:
get :contacts, :show do fetch_model_for_id(Contact, params[:id]) end