Gustavo Garcia

Joined

1,860 Experience
18 Lessons Completed
0 Questions Solved

Activity

Posted in Deploy Ubuntu 22.04 Jammy Jellyfish Discussion

My fault. This fixed it:
chmod o+x $HOME

Posted in Deploy Ubuntu 22.04 Jammy Jellyfish Discussion

Thanks a lot for this step by step guide!
Anyway, I'm facing a problem with Passenger. After deploying the app, I see this in the nginx logs:

Error opening '/home/deploy/my_app/current/Passengerfile.json' for reading: Permission denied (errno=13); This error means that the Nginx worker process (PID 48756, running as UID 33) does not have permission to access this file. Please read this page to learn how to fix this problem: https://www.phusionpassenger.com/library/admin/nginx/troubleshooting/?a=upon-accessing-the-web-app-nginx-reports-a-permission-denied-error;

But I don't have any file called Passengerfile.json in my app's directory. Any clue?

Thank you very much for this video, Chris! I just wanted to share here a little update I had to do in order to make it work:
1) the new postgres images require a password, so I had to add it as an env variable.
2) actions/setup-ruby is deprecated, now you have to use ruby/setup-ruby instead
3) the borales/actions-yarn is now at v2.3.0, the 2.0.0 is not working anymore

So the final version of this setup looks like this one:

# .github/workflows/ci.yml

name: CI
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    services:
      db:
        image: postgres
        env:
          password: secretpassword
        ports: ['5432:5432']
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
      redis:
        image: redis
        ports: ['6379:6379']
        options: --entrypoint redis-server

    steps:
      - uses: actions/checkout@v1
      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.6.x
      - uses: borales/actions-yarn@v2.3.0
        with:
          cmd: install
      - name: Build and run tests
        env:
          DATABASE_URL: postgres://postgres:secretpassword@localhost:5432/test
          REDIS_URL: redis://localhost:6379/0
          RAILS_ENV: test
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          sudo apt-get -yqq install libpq-dev
          gem install bundler
          bundle install --jobs 4 --retry 3
          bundle exec rails db:prepare
          bundle exec rails test

You can avoid that turbo_stream template by putting everything in the controller, like this:

respond_to do |format|
  format.html { redirect_to tweets_path, notice: "Your tweet was successfully created." }
  format.json { render :show, status: :created, location: @tweet }
  format.turbo_stream { render turbo_stream: turbo_stream.prepend('tweets', partial: 'tweets/tweet', locals: { tweet: @tweet })}
end

But I personally liked a lot this approach of adding a proper template for the turbo_stream response.

Thanks a lot for this video, Chris!

Posted in Hotwire Modal Forms Discussion

Thanks a lot for this video! I see it's becoming a trend to add a format.turbo_stream response in all my controllers only if it fails.

I'm having the same issue...
ruby: 2.7.2
rails: 6.1
turbo-rails: 0.5.3 (7.0.0-beta.3)

I'm using the turbo_frame_tag 'report_form' wrapping the form and in the controller I have

def create
    @report = Report.new(report_params)
    respond_to do |format|
      if @report.save
        format.html { redirect_to @report, notice: "Report was successfully created" }
        format.json { render :show, status: :created, location: @report }
      else
        # format.turbo_stream { render turbo_stream: turbo_stream.replace(@report, partial: 'reports/form', locals: { report: @report })}
        format.html { render :new, status: :unprocessable_entity }
        format.json { render json: @report.errors, status: :unprocessable_entity }
      end
    end
  end

The commented line also works, in that case, the response for the error only renders the form partial, but I still have the same problem for the success... nothing happens.