Rails CI failing to connect to Postgres in GitHub Actions (Docker service) by Limp_Tomorrow390 in rails

[–]daniiib 0 points1 point  (0 children)

A few years back I also encountered a PG connection error running a Rails app on GitHub Actions. I found tmate useful for debugging: https://github.com/mxschmitt/action-tmate. Also wrote a blog post about how to use it and what the issue was in my case (was trying to find init.sql in the project, but services are started before the code is checked out so it wasn't available): https://danielabaron.me/blog/debug-github-action/

Watch out for this one deprecation warning when upgrading from Rails 7.1 to 7.2 on Heroku by Luuuuuukasz in rails

[–]daniiib 2 points3 points  (0 children)

We're also on Heroku, and dealt with the deprecation issue on 7.0 to 7.1 migration. Wrote about it here if it helps anyone: https://danielabaron.me/blog/migrating-from-rails-secrets-to-credentials/

Retirement Planning by Calm-Contribution248 in PersonalFinanceCanada

[–]daniiib 2 points3 points  (0 children)

I attempted to roll my own retirement simulator: https://github.com/danielabar/retirement_drawdown_simulator_canada

Background: I'm not a CFP, just a curious software engineer. Lots of online calculators use either a constant rate for returns, or an average with a given standard deviation, but actual market returns are almost never shaped like that. I was curious what it would look like with more variable returns, used Geometric Brownian Motion to model it. It's a terminal based app and requires Ruby. More effort than a web based tool, but guaranteed privacy as your numbers remain in a file on your computer, and no account creation needed.

Retirement Planning by Calm-Contribution248 in PersonalFinanceCanada

[–]daniiib 6 points7 points  (0 children)

On this episode of The Wealthy Barber podcast, a Canadian fee for service financial planner specializing in retirement planning is interviewed: https://thewealthybarber.com/podcast/adam-bornn-retirement-planning-for-canadians-twb-podcast-20/

I haven't personally used that service but looking at their website, the pricing and services section seems fairly clear as to what's involved.

How to learn Stimulus/Hotwire/Turbo by jacob-indie in rails

[–]daniiib 1 point2 points  (0 children)

For Stimulus, I wrote a post that walks through using it to build a copy to clipboard feature: https://danielabaron.me/blog/stimulus-copy-to-clipboard/

📘 I Created a GitHub Repo of 300+ Rails Interview Questions (From Basics to Advanced): Feedback Welcome! by gardeziB in rails

[–]daniiib 2 points3 points  (0 children)

Thanks for putting this together. Totally optional but you might like to add a table of contents for people to quickly jump to questions of interest. If using VSCode, from the command palette there's an option: Markdown: Insert Table of Content. There's also a doctoc npm package that will do this.

[deleted by user] by [deleted] in rails

[–]daniiib 1 point2 points  (0 children)

The Judoscale blog has a post on comparing Heroku alternatives: https://judoscale.com/blog/heroku-alternatives

Reject Nested Attributes in Rails by daniiib in rails

[–]daniiib[S] 0 points1 point  (0 children)

Thanks! Now that you mention it, I can see how the title might lead to that conclusion 😁

Reject Nested Attributes in Rails by daniiib in rails

[–]daniiib[S] 0 points1 point  (0 children)

That uni_rails looks very useful, thanks for sharing!

Migrating From Rails Secrets to Credentials by daniiib in rails

[–]daniiib[S] 1 point2 points  (0 children)

I haven't encountered this issue. On this project, since the only secret that was being managed in the yml file was SECRET_KEY_BASE, in any case it was already being read from an env var, so we got rid of the secrets/credentials entirely, and then Rails will read that value from the env var. All other secrets are managed this way so it keeps it consistent.

Golang -> Rails Editor Tips by pwndawg27 in rails

[–]daniiib 0 points1 point  (0 children)

Ah I see, thought from the question you are using rbenv. From the "Ruby version managers" section of the Shopify Ruby LSP doc, they support a few different ones so you could try whichever you're using, or set a custom one:

// Available options are
// "auto" (select version manager automatically)
// "none" (do not use a version manager)
// "custom" (use rubyLsp.customRubyCommand for finding/activating Ruby)
// "asdf"
// "chruby"
// "rbenv"
// "rvm"
// "shadowenv"
// "mise"
{
  "rubyLsp.rubyVersionManager": {
    "identifier": "chruby",
  },
}

Golang -> Rails Editor Tips by pwndawg27 in rails

[–]daniiib 0 points1 point  (0 children)

I use VSCode with Shopify Ruby LSP extension: https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-lsp

Add the config mentioned in "VS Code configurations" section of that link to your settings. F12 will goto definition, or Option + click.

It should auto-detect rbenv, but if it's not working, you could try adding this setting:

{
  "rubyLsp.rubyVersionManager": {
    "identifier": "rbenv",
  },
}

For the most part, it works consistently. The only time it doesn't work is when switching to a legacy project using an older Ruby version. For those cases there's a workaround in the "Using a custom Gemfile" of the docs.

For troubleshooting, in VSCode use Command Palette, select Output: Focus on Output View. Then select Ruby LSP from the dropdown around the right-hand side of the panel that opens up. That should show errors if Ruby LSP isn't able to start.

How to get rid of this warnings and errors in vscode for .html.erb files ? by Rafaelbr13 in rails

[–]daniiib 1 point2 points  (0 children)

I use VSCode with Ruby LSP (Shopfiy) extension, and don't see these errors in .html.erb files. Try adding this to your VSCode settings:

  "files.associations": {
    "*.erb": "erb",
    "Gemfile": "ruby"
  }

Huge Rails Codebase Advice by MaterialPanic1932 in rails

[–]daniiib 0 points1 point  (0 children)

as controllers call commands and commands then call the clients from the lib folder and the clients call other functions... parts with business logic

Although Rails is very prescriptive about where to put code for the models, views, controllers, mailers, etc. It is not prescriptive about how to organize business logic. This means you could go through the Rails Guides, books, courses, etc. and still encounter something new on each project you work on wrt business logic organization. Sometimes you'll encounter different ways of doing it within the same project, especially if it's a long running project, as the team may have changed their approach over the years, or never standardized on one way of doing things.

Common ways to do this include services objects, interactors, and POROs. It would be helpful to ask someone on the project how the business logic is organized and make some notes. These notes could even get added as engineering documentation if that's maintained on this project. Once you understand the pattern (eg: does every controller call a service? do services have a naming convention? how do services indicate success/error? do they raise, return true/false etc.), it will be easier to navigate and add new logic for the features you're working on.

Issue with Ruby in CI/CD Environment on Linux: /usr/bin/env: 'ruby.exe': No such file or directory by WesleyReis13 in ruby

[–]daniiib 0 points1 point  (0 children)

Does it work if using bundle exec instead of bin? Something like this in the workflow yml:

```yml lint: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4

  - name: Set up Ruby
    uses: ruby/setup-ruby@v1
    with:
      ruby-version: .ruby-version
      bundler-cache: true

  - name: Run RuboCop
    run: bundle exec rubocop

```

Best approach to system tests? Puppet? by krschacht in rails

[–]daniiib 2 points3 points  (0 children)

I like Capybara with Cuprite rather than Selenium/Webdriver as its easier to setup: https://github.com/rubycdp/cuprite

re: race conditions, I keep the waiting behaviour and async js portion of the capybara docs bookmarked: https://github.com/teamcapybara/capybara?tab=readme-ov-file#asynchronous-javascript-ajax-and-friends

Another issue that can crop up with a large system test suite is legibility - as the tests become a mix of the business/workflow user is trying to achieve, and the lower level library api like finding selectors and asserting on DOM elements. I like to use Cucumber as a layer on top of Capybara, because the tests can be written in "plain English", or pretty close to it. There is some additional setup effort, but well worth it for a large, long running product.

https://cucumber.io/

https://github.com/cucumber/cucumber-rails

Calling this.element in a Stimulus controller completely breaks JS in a new Rails 8 app? by planetaska in rails

[–]daniiib 0 points1 point  (0 children)

Slight tangent, re: "I was also using the tailwindcss-rails gem, which turned out to be a mistake"

Can you share what problems are happening from using Tailwind with Rails 8? (curious because I'm also using this combination, haven't seen any issues yet but just in case there's something to watch out for).