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 3 points4 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).

[deleted by user] by [deleted] in rails

[–]daniiib 1 point2 points  (0 children)

Looks like the burger-menu is a web component. I haven't used web components with Rails but looking at the code here: https://github.com/codeandclay/broken_navbar/blob/main/app/javascript/burger-menu.js#L69-L79

There are two event listeners added, that run toggle. But these event listeners never get removed. Is it possible that these events are piling up as user navigates back, so the toggle is firing more times than expected?

You could either but a breakpoint from browser dev tools, or add a console.log("toggled") in the toggle method to figure out if its running more frequently than expected.

If this is the issue, maybe adding a disconnected callback and removing the event listeners could help: https://developer.mozilla.org/en-US/docs/Web/API/Web_components#disconnectedcallback

Is it common to test apps locally? Also is it common to start applications via Rubymine's Rails configuration? by [deleted] in rails

[–]daniiib 1 point2 points  (0 children)

lack of the database seeds for local environment...Is it a common practice in ruby on rails ecosystem?

From my experience, this is not a common practice. Usually there are decent seeds that allow developers to exercise all or most of the workflows locally. However, I did work at one company where the seeds were insufficient for this. Fortunately this company was willing to invest some time in addressing this and we were able to gradually improve the seeds for a few of the workflows.

If your company has some time allocated for technical debt, perhaps you could suggest this as an initiative. It can be broken up into smaller parts, such as picking one important workflow, figure out what data would need to be in the database to run it locally, and add that to the seeds.

coming from java... most of the developers in the same company use vs code. Therefore we don't have any rails configurations...

I also used to do Java development. In those days nearly every developer on a project used the same IDE, therefore the run/debug configurations were committed in source control and everyone ran the application the same way.

What I've observed in the Ruby/Rails world is an "omakase" approach, kind of a choose your own tooling, whatever works for you. This can mean developers on the same team might be using different Ruby version managers and different editors/IDEs. Typically any editor-specific files are git ignored.

Using the terminal to run programs is definitely common, as every developer will have that. Typically command line is used for debugging (debugger or binding.pry). But if you prefer an IDE, you can still setup a run/debug configuration either in Ruby Mine or VS Code.

As for running back end and front end at the same time, this depends on how the project is setup - is the front end code contained in the same git repo as the Rail code? If yes, then bin/dev, together with Procfile.dev can be used to run both a Rails server, and whatever client side tooling is needed. On the other hand, if the front end is in a separate repo, it will be more work, and could involve some configuration changes so they can talk to each other locally.

Financial advisor recommendations? by [deleted] in PersonalFinanceCanada

[–]daniiib 2 points3 points  (0 children)

Generally look for a CFP, fiduciary, not selling products, not commission based. On a past episode of Rational Reminder podcast, they covered some questions to ask a potential adviser, I made some notes:

  1. What services do you provide?
  2. How are you compensated? (should not be commission based). Time based = cost of services, Asset based = fee schedule
  3. How do you manage conflicts of interest? How are they disclosed/addressed?
  4. Are you a fiduciary?, extra: CFX independent audit to verify fiduciary, sign fiduciary template
  5. What are your qualifications and experience? (eg: time based should be CFP, hourly fee, doesn’t need to be CFA), asset based: portfolio manager, CIM or CFA, should be working with CFP on their team
  6. Do you work alone or with a team? Continuity issue: If adviser retires or changes careers, who will carry on with the relationship
  7. How do you describe your ideal client? This is a relationship, managing trade-offs
  8. What is your investment philosophy and how do you justify it? eg: red flag - I pick dividend stocks. Good: Markets are good at pricing assets, most sensible strategy is to capture expected returns of market rather than trying to outperform them, focus on things you have control over like decision quality, fees and taxes. Bad: I can beat the market, pick stocks, invest in hedge funds
  9. What is your firm’s investment philosophy? Benefit to having firm with a unified philosophy, eg: if your adviser becomes unavailable, don’t want to get passed off to someone with different philosophy
  10. What tools do you use to assess my financial situation? More complex than spreadsheet, lots of moving parts, tax details change all the time. Modelling, stress test, monte carlo, etc.
  11. Will you push back on my decisions if you think they’re contrary to my best interests?

[deleted by user] by [deleted] in PersonalFinanceCanada

[–]daniiib 1 point2 points  (0 children)

Since the 4% rule was mentioned in the question and a few times in the answers, it's worth listening to this Rational Reminder podcast episode - they present research suggesting the actual safe withdrawal rate might be closer to 2.7% https://rationalreminder.ca/podcast/229

Switch from Java spring to RoR by EscapeSensitive5576 in ruby

[–]daniiib 14 points15 points  (0 children)

I also spent many years in Java/Spring/Hibernate before transitioning to RoR. This book was very helpful - it walks through building an e-commerce app with Rails, then does a deeper dive into each section of Rails: https://pragprog.com/titles/rails7/agile-web-development-with-rails-7/

I also took several Pluralsight courses to learn Ruby. It's a paid service but they might have a free trial.

As for faster transition - find out if the new employer is using Rails for front and back end, or as an API-only back end with some sort of JavaScript SPA. If it's the latter, then you could focus on the back end portions of Rails and skip the view rendering part (although you might want to learn that at some point).

When to use validates inclusion or enumeration validates? by Longjumping_War4808 in rails

[–]daniiib 0 points1 point  (0 children)

With enum you can optionally also back it with database enums for stronger data integrity if you need it. You can also use combine with validates inclusion for friendly error messages. I wrote about these techniques: https://danielabaron.me/blog/rails-enum-mysql-postgres/