{"id":15912833,"url":"https://github.com/abeidahmed/micro-reddit","last_synced_at":"2026-04-26T12:32:36.818Z","repository":{"id":54785486,"uuid":"333690777","full_name":"abeidahmed/micro-reddit","owner":"abeidahmed","description":"A simple rails console app based on the popular reddit platform.","archived":false,"fork":false,"pushed_at":"2021-01-29T12:29:23.000Z","size":186,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"development","last_synced_at":"2025-04-03T03:15:45.328Z","etag":null,"topics":["rails","reddit"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abeidahmed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-28T08:15:35.000Z","updated_at":"2021-01-29T19:01:27.000Z","dependencies_parsed_at":"2022-08-14T02:51:39.482Z","dependency_job_id":null,"html_url":"https://github.com/abeidahmed/micro-reddit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abeidahmed/micro-reddit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeidahmed%2Fmicro-reddit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeidahmed%2Fmicro-reddit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeidahmed%2Fmicro-reddit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeidahmed%2Fmicro-reddit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abeidahmed","download_url":"https://codeload.github.com/abeidahmed/micro-reddit/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abeidahmed%2Fmicro-reddit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32297894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rails","reddit"],"created_at":"2024-10-06T16:21:21.400Z","updated_at":"2026-04-26T12:32:36.795Z","avatar_url":"https://github.com/abeidahmed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micro Reddit\n\nA simple rails console app based on the [reddit](https://reddit.com) platform.\n\n## Getting started\n\n- Clone the repo `https://github.com/abeidahmed/micro-reddit.git`\n- `cd` into the directory\n- Run `git checkout -b reddit-model-feature`\n- Run `git pull origin reddit-model-feature`\n- Run `bundle install`\n- Setup your db, and run `rails db:create db:migrate`\n\n## Features\n\n- Users can register themselves\n- Create a post\n- Comment on a post\n- Comment on a comment\n- Reddit style upvotes and downvotes on both posts and comments\n- Bookmark posts and comments\n\n## Usage\n\nThe first thing that you need to do is to fire up a `rails console`.\n\nLet's get started by creating a `user`.\n\n```ruby\nuser = User.create!(full_name: 'John Doe', email_address: 'johnny@ex.com', password: 'secretpassword')\n=\u003e #\u003cUser id: 1, full_name: \"John Doe\", email_address: \"johnny@ex.com\", password_digest: [FILTERED], ...etc\u003e\n\n# Try quering `user.password`, you'll probably get `nil`. This is because the password's are hashed before storing.\n```\n\n\u003e Before storing the `email_address`, they are normalized and checked for a valid `email_address`.\n\nNow, let's create a post. We will reference the above created `user` when creating a `post`.\n\n```ruby\npost = user.posts.create!(title: 'My first blog post', content: 'Hello world, an awesome day indeed')\n=\u003e #\u003cPost id: 1, title: \"My first blog post\", content: \"Hello world, an awesome day indeed\", votes_count: 0, user_id: 1, .... etc\u003e\n```\n\n\u003e This creates a `post` and the `user_id` column is populated with the `user`'s id.\n\nNow, let's comment on the post that we created above. Because that's what reddit does right?\n\n```ruby\ncomment = post.comments.create!(content: 'Wow, an awesome post', user: user)\n=\u003e #\u003cComment id: 1, content: \"Wow, an awesome post\", votes_count: 0, commentable_type: \"Post\", commentable_id: 1, user_id: 1, ... etc\u003e\n```\n\n\u003e Comment is created and the `post_id` and the `user_id` is populated automatically.\n\nYou want to comment on a comment? No problem\n\n```ruby\nnested_comment = comment.comments.create!(content: 'I am a nested comment', user: user)\n=\u003e #\u003cComment id: 2, content: \"I am a nested comment\", votes_count: 0, commentable_type: \"Comment\", commentable_id: 1, user_id: 1, ...etc\u003e\n```\n\nPhew, we did a lot. But we still have more to go. Let's try the upvote and the downvote feature.\n\n```ruby\npost.upvote\n=\u003e #\u003cVote id: 1, votable_type: \"Post\", votable_id: 1, ...etc\u003e\n\n# This creates a `vote` instance on the `post`.\n\npost.votes_count\n# 1\n\npost.downvote(1) # Here 1 is the `id` of the vote that we created earlier. Normally, we could have used the controller to fetch the params and pass in the argument.\n# DELETE FROM \"votes\" WHERE \"votes\".\"id\" = $1  [[\"id\", 1]]\n\npost.votes_count\n# 0\n```\n\nSimilarly, lets vote on the comment\n\n```ruby\ncomment.upvote\n=\u003e #\u003cVote id: 2, votable_type: \"Comment\", votable_id: 1, ...etc\u003e\n\ncomment.votes_count\n# 1\n\n# and\n\ncomment.downvote(2) # The `id` may change here. Please be cautious.\n=\u003e #\u003cVote id: 2, votable_type: \"Comment\", votable_id: 1, ...etc\u003e\n\ncomment.votes_count\n# 0\n```\n\n\u003e The count feature is handled by the [`counter_cache`](https://api.rubyonrails.org/classes/ActiveRecord/CounterCache/ClassMethods.html) column.\n\nSimilarly, lets vote on a nested comment\n\n```ruby\nnested_comment.upvote\n=\u003e #\u003cVote id: 3, votable_type: \"Comment\", votable_id: 2, ...etc\u003e\n\n# and\n\nnested_comment.downvote(3) # The `id` may change here. Please be cautious.\n# DELETE FROM \"votes\" WHERE \"votes\".\"id\" = $1  [[\"id\", 3]]\n```\n\nLast but not the least, the bookmark or the save feature as reddit likes to call it.\n\n```ruby\npost.bookmarks.create! user: user\n=\u003e #\u003cBookmark id: 1, bookmarkable_type: \"Post\", bookmarkable_id: 1, user_id: 1, ..etc\u003e\n\ncomment.bookmarks.create! user: user\n=\u003e #\u003cBookmark id: 2, bookmarkable_type: \"Comment\", bookmarkable_id: 1, user_id: 1, ...etc\u003e\n\nnested_comment.bookmarks.create! user: user\n=\u003e #\u003cBookmark id: 3, bookmarkable_type: \"Comment\", bookmarkable_id: 2, user_id: 1, ...etc\u003e\n```\n\nAnd similarly you can `update` and `destroy` the records accordingly.\n\n## Authors\n\n### Abeid Ahmed\n\n- GitHub: [@abeidahmed](https://github.com/abeidahmed)\n- Twitter: [@iamhawaabi](https://twitter.com/iamhawaabi)\n- LinkedIn: [Abeid Ahmed](https://www.linkedin.com/in/abeidahmed/)\n\n### Martin Nyagah\n\n- GitHub: [@menyagah](https://github.com/menyagah)\n- Twitter: [@Martinnyaga20](https://twitter.com/Martinnyaga20)\n- LinkedIn: [Martin Nyagah](https://www.linkedin.com/in/martin-nyagah-a29b8610b/)\n\n## Contributing\n\n- Fork the project\n- Create your feature branch `git checkout -b awesome-feature`\n- Commit your changes `git commit -m 'Awesome feature'`\n- Push it `git push -u origin awesome-feature`\n- Open a pull request using this branch\n\n## License\n\n[MIT](https://github.com/abeidahmed/tic-tac-toe/blob/development/LICENSE) licensed software.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabeidahmed%2Fmicro-reddit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabeidahmed%2Fmicro-reddit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabeidahmed%2Fmicro-reddit/lists"}