Comments (9)
I know this is old, but since it's open i would like to pitch in. I am a happy user, but have gone beyond read-only
With little effort i use activehash as a simple file based db. For very similar reasons that the project was created for.
Ie very small data, with little change
migration of data from dev->production (ie checking files in)
I have written a small cms and use ActiveHash files as store. All edits happen on developer machines and so content changes flow in the same way as code canges.
I would be happy to contribute code if the project maintainers want to go to read/write
from active_hash.
@rubydesign is there a reason why you don't want to use active record and SQLite?
If the discussions are any indication, it seems many users want to go in this direction. I was curious for the reason. Understanding the reasoning is the best way to properly meet those needs.
Then we can possibly update the goal in the Readme. We can also use this to guide our future direction
from active_hash.
On my current project, we use fixture files snd populate Postgres using rake db:seeds
.
from active_hash.
@kbrock Thanks for asking, i did not expect this to be picked up. But as i said, i am a happy read/write user and would be happy to contribute back. For me the functionality has been very helpful.
My use case is quite simple, the data is generated in development/staging environments. So db is not an option. Files are useful because the whole development process works around files.
Then the question is, why do i generate data in development/staging. I think the answer is very very similar to the original project use case.
Two concrete examples, mine and one i have run into before
- in my use case i have content writers create static content. Since they are not devs, i can't give them haml to work on. I built a mini cms that uses ActiveHash as a db. My cms is basically a bespoke yaml editor. The yaml goes into git and ends up on the site, like any other changes.
- Translations are another use case. I have built many multi-lingual sites and it is always a pain to keep translations in sync. Again non-devs would do the translation in a dev/staging system. Again edit yamls in a very bespoke way.
My needs are currently met in a single-user, non threaded implementation. Ie upon change i write all files out.
https://github.com/FeenixMakers/merged/blob/main/app/models/merged/active_base.rb#L35
I've tried to keep the AH changes in that file. There are other "models" there that are based on AH, they are close enough to AR to work in basic crud controllers.
from active_hash.
@rubydesign thanks.
- You run a server locally and people use that server to add/edit values.
- Then you go to that server and commit the yaml file into git
- git pull in production
- Production runs off of the yaml
- Production does not change the yaml files.
That makes sense.
Storing yaml text data in git handles merge conflicts better than a bin file. So it would require adding imports and exports and a bunch of complexity.
I've only ever used active hash for developer edited yaml files. My current team uses pot (via gettext) files for translations which are used across many ruby gems, languages, and frameworks.
I just look at the complexities we are adding around mutexes, defaults, or quicker id generation. The new use cases seem like we're duplicating a standard rails database adapter.
from active_hash.
@kbrock That's the use, mostly, yes. And it is very useful (for me at least). I would imagine for translations too.
The use cases have make the system usually single threaded, single user. A little really goes a LONG way.
Conceptually it is a step along the db adapter, yes. But i tried writing one of those once and the basic crud is really just the small tip of the iceberg. I mean in reality it's nothing like a db adapter, at least in terms of effort.
Really a simple save for a collection would be enough. If you look at the method i linked, that's does a lot. I never understood why i have to do a reload there, but that simple save would be a good start that goes a long way.
PS: sorry about the intermittent communication, i am in the mountains of Tuscany and there is surprisingly bad network coverage.
from active_hash.
I'm not a very active maintainer at this point, so feel free to discount my opinion; but I think it's a very bad idea to try to turn this gem into a transactional database. That is surely going to be a ton of work to do correctly, and will greatly increase the demands on the maintainers and the support burden (and I'm personally not prepared or willing to take that on).
If people need something more advanced than a yaml file then I would strongly recommend looking into using a sqlite database that can be deployed with the app.
If anyone feels super strongly that they want to go in this direction: would you consider forking this project to try to support those more advanced use cases, rather than introducing that complexity here?
from active_hash.
Hey @flavorjones
My issue is that we seem to already be going in this new direction.
And it scares me. I'm curious if that is intentional.
examples:
- introducing a mutex #229
- quicker id creation #231
- creating a json datasource. #203
- some
default
field behavior that doesn't modify base data hash (can't find)
A read only database probably doesn't need a mutex or id creation. Right?
I wanted to know if others felt we were starting to veer in this new direction and see how they felt about this.
from active_hash.
Ok, since i have been pro saving here i just want to retract that. I fully understand that open source is collaboration and not making feature requests and don't want to add to anyone's burden.
It just took me a couple of days to rewrite everything that i need, which includes save. Not multi threaded, and no ActiveRecord relations. just 140 lines of dense code that does what i need
https://codeberg.org/FeenixMakers/staged/src/branch/main/app/models/staged/active_yaml.rb
Thanks for the code/ideas i lifted and the code i used before. (torsten out)
from active_hash.
Related Issues (20)
- Release master for Ruby 3 compatibility HOT 16
- ActiveRecordExtensions.belongs_to with extra arguments is not working HOT 3
- Using ActiveHash::Associations and JSONAPISerializer at the same time will result NoMethodError. HOT 1
- Can a class that inherits from ActiveHash::Base be associated with another class that inherits from ActiveHash::Base? HOT 1
- The has_many :through Association does not get record HOT 6
- QUESTION: What's the performance of "find_by"? HOT 2
- Scopes are not chainable HOT 1
- Rails 7 finding a valid model association. HOT 6
- Rails 7 Compatibility HOT 4
- Make releases more often? HOT 3
- ActiveHash scope affecting self HOT 3
- Reflection Inheritance Issue HOT 4
- 3.2.0: Regression in `.where`? HOT 7
- No Method Error for find_by and find HOT 1
- `ActiveHash::Relation` returned by `ActiveHash#where` should be reported like as an array of `ActiveHash` items selected by `where` method, in Rails Console. HOT 3
- ActiveHash::Relation can not use respond_to? method HOT 3
- find_by with nil value will return an object with an empty string
- undefined method `find_by_key' for ActiveYamlBaseClass:Class Did you mean? find_by_id HOT 3
- Accessing belongs_to association without a key creates a useless query HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_hash.