Ali Hamdi Ali Fadel

Joined

1,240 Experience
1 Lesson Completed
1 Question Solved

Activity

Most welcome, I love Rails, but I hope that the community is more responsive tbh.

Hello everyone, I learnt about devcontainers weeks ago and start using them and they are very helpful and easy to use. So, I putted this GitHub repo with a starter devcontainer template to setup any Rails project with PostgreSQL, Redis, MeiliSearch, Memcached, Firefox, and multiple Ruby/Rails VSCode extensions:

https://github.com/AliOsm/ruby-on-rails-devcontainer

Using this setup, you can run your development environment anywhere and the only dependencies are Docker Desktop and VSCode, which is very easy to install them. The good part is when you start utilizing GitHub Codespaces with this setup, I can develop my projects everywhere, and I don't need my laptop/desktop to be with me. I just need a browser.

I hope this will be helpful for you also.

The answer now exists in the StackOverflow question.

I'm working on a project that has Cue model that could be accessed and searched by multiple roles like guest and admin. The authorization happens using CanCanCan gem based on some logic written in the Ability class. While the search happens using Pagy/MeiliSearch combination to do the full text search and the pagination. The issue I'm facing now is when I search as a guest, I can see the correct items a guest should see, and when I search as an admin, I can see the correct item an admin should see, BUT Pagy gem counts are incorrect. This is my code:

class SearchesController < ApplicationController
  INCLUDES = %i[medium speakers].freeze

  include Pagy::Backend

  authorize_resource class: false

  def search
    filter = ''
    filter = "speaker_ids IN [#{params[:speaker]}]" if params[:speaker].present?

    search_results = Cue.accessible_by(current_ability).includes(INCLUDES).pagy_search(params[:query], filter:)
    @pagy, @search_results = pagy_meilisearch(search_results)
  end
end

If there are some cues not accessible by a guest, the search will not return them in @search_results, but the @pagy object will count them in. This shows incorrect counts to the user and also shows less than the required Pagy::DEFAULT[:items]. I tried a lot of options, but with no success. The only thing I can think about (And I don't want to go this path TBH) is to add the filtering logic itself into the filter string and add the required parameters to the index. But this will be complicated and it will increase the index size. Do you have any thoughts?

If you have the budget, look into HatchBox, it is very easy to use. If you want to use something free, look into capistrano.

Posted in How will HatchBox handle manually installed software?

I'm using the go to production guide provided by meilisearch documentation which sets up meilisearch using bash scripts, in this way how HatchBox will handle this?

Posted in Devise and Turbo-rails

I'm using Rails 7.0.4 and Devise bundled directly from Devise GitHub repo:

gem 'devise', github: 'heartcombo/devise', ref: 'f8d1ea90bc3'

I did multiple things to make it working with Turbo, but I didn't notice the rendering_options issue.
Could you please collaborate more?

Posted in How will HatchBox handle manually installed software?

If I installed meilisearch on my server that is managed by HatchBox, how it will handle meilisearch binaries in server updates and deployments?

Posted in Where to store images?

Any thoughts ?,?

Posted in Could I deploy two different apps on the same server?

BTW Chris, I think there is a bug (or a feature :3) in GoRails forum. When I publish a new question, my old question disappears from the All Threads listing. This is my new question: gorails . com/forum/where-to-store-images-a758fc64-78b7-472d-9ddb-899d71522c09, and this is the old one: gorails . com/forum/could-i-deploy-two-different-apps-on-the-same-server-90fca78a-8dac-481f-957c-2a9b902a4dd4 (The current one).

Also, only one of them appears in My Questions listing.

I put spaces as you detected that I'm a spammer, sorry :3

Posted in Where to store images?

Hello everyone,

I'm working on a Rails app that should handle 20K-30K images in the first year, and I was thinking about where to store the images. I thought about local storage, but this will have multiple issues like the space and backups. Also, I thought about AWS S3 and similar solutions, but they will be costy over time. I want to hear from you based on your experience.

Thanks in advance!

Posted in Could I deploy two different apps on the same server?

No nothing special I'm thinking of, I was just making sure that I'm understanding the process correctly. Although, one thing is questionable for me, will HatchBox handle the port thing itself? Like booting one app on 9000 and the other on 9001?

Posted in Could I deploy two different apps on the same server?

Hello Chris,

It makes sense, but my question is that we don't have to do any extra setups, right? Just create new app and deploy it to the same server?

Another question, is it easy to migrate from one server for 2 apps to 2 different servers one for each app?

Posted in Could I deploy two different apps on the same server?

Hello everyone,

Yesterday, I started using HatchBox to deploy my Rails applications and it is working just fine.

I was thinking about deploying 2 Rails applications on the same Vultr | 1GB RAM | 1 vCPU instance, known that the 2 applications will be used by <1000 users per month, and one of them is not DB intensive application. Do you have any thoughts about this?

Also, is there any special setup to do? Or I should just create new App in HatchBox and deploy it to the same server?

Thanks in advance!

Posted in Where to store images?

Hello everyone,

I'm working on an application and I expect a lot of images to be uploaded on it. I don't have estimates yet, but I think they will be in the range of 20K-30K images in the first year.

I'm using ActiveText to provide rich text content to my users, and I was thinking about where to store the images. Should I store them locally, or should I go to AWS S3 and similars?

Do you have any thoughts?

Thanks in advance!

Posted in Could I deploy two different apps on the same server?

Hello everyone,

Yesterday, I started using HatchBox to deploy my Rails application, and I deployed 1 application successfully. The process is clear and straight-forward.

My question is could I deploy two different applications on the same Vultr | 1GB RAM | 1 vCPU instance? Known that the application users are in hundreds and one of them is not DB intensive application.

If the answer is yes, is there any special setup? Or I should just create new App on HatchBox and deploy it to the same server?

Thanks in advance!