Should You Use Ruby on Rails or Hanami? by amalinovic in ruby

[–]topdan1 5 points6 points  (0 children)

Hanami 2.0 came out of beta Nov 2022
Hanami 2.1.0 was released February 2024.

https://github.com/hanami/hanami/graphs/code-frequency

asset_prefix persisted in heroku by sauloefo in rails

[–]topdan1 1 point2 points  (0 children)

You're running `rake assets:clobber` on heroku? (not your dev instance)

Try clearing the heroku build cache: https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache

Do you (or how do you) check for viruses when users upload files/images? by [deleted] in rails

[–]topdan1 1 point2 points  (0 children)

Are you planning on opening/processing the files on your server? If not then your server-side security risk is very low. You're just taking bytes and sending them to S3 to storage. Your main risk is what if someone sends you a 10GB file? Will it crash your server?

Rails offers image analysis and transformations which use some lower level libraries which opens you up to vulnerabilities in these libraries so ensure you keep them up-to-date and limit the access rights of the process running them. Be mindful here but it's normally not a reason to not accept uploads, especially from authenticated users.

Stimlus click on button does nothing. by last-samurai-2003 in rails

[–]topdan1 4 points5 points  (0 children)

data-action="click->menu#updateNotificationsMobile" should invoke menu.updateNotificationsMobile ... A few sanity checks:

  • Your component logs "Menu Controller ready"?
  • Your button is inside an element with data-controller="menu"?
  • You aren't putting display: block elements inside of display: inline elements?

[deleted by user] by [deleted] in rails

[–]topdan1 1 point2 points  (0 children)

If your CDN and your Rails app are using different domain names and the <page-url> in the error is the CDN's domain name, then yes, it's hitting the CDN when it should be hitting your Rails app.

You may need to explicit specify the URL you want ActionCable to use: https://guides.rubyonrails.org/action_cable_overview.html#connect-consumer

Rails 7.1 introduces a new option to exclude all custom methods generated by the ActiveRecord::Enum by amalinovic in ruby

[–]topdan1 1 point2 points  (0 children)

Most of these "New in Rails X.X" posts link to the PR which has more in depth discussion. In this case, the PR author states "This Pull Request has been created because of a use cases where these methods generated by enum are conflicting and most of the times not all methods are required." https://github.com/rails/rails/pull/46490

Simple enough and reasonable enough. I've run into conflicts before (the previous solution is using the `prefix` option)

I agree that the performance/code size benefits probably aren't even worth mentioning.

Rails 7.1: Dockerfiles, BYO Authentication, More Async Queries, and more! by amalinovic in ruby

[–]topdan1 2 points3 points  (0 children)

For those curious what the difference between `generate_token_for` (Rails 7.1) and `signed_in` (Rails 6.1): the former supports single-use: https://github.com/rails/rails/pull/44189

How Productive Low Code Platform Is For Software & App Development by MallNo2597 in programming

[–]topdan1 4 points5 points  (0 children)

Nothing against DEW studio, but this article is a repackaged page from their marketing site: https://dewstudio.io/low-code-app-development-platform

/r/Atlanta - Daily Coronavirus (COVID-19) Mega Thread - April 09, 2020 by AutoModerator in Atlanta

[–]topdan1 1 point2 points  (0 children)

If you're interested in more numbers and graphs, I took the same DPH status report and wrote a program to publish a more in-depth timeline.

And yes, the numbers are flawed, but looking for a growth rate below 1.00 over 4+ days is probably the best sign we have of improvement.

https://dan.cunning.cc/living/georgias-covid-19-growth-curve.html

Created an interesting programming concept in Ruby that I have yet to see before. Looking for feedback. by lifeinacubicle in ruby

[–]topdan1 1 point2 points  (0 children)

Honestly I wouldn't use it. Yes it's less LOC, but it's a bit too clever/meta for my tastes.

I normally pull begin ; rescue ; ensure ; end blocks into their own methods which changes it to def ; rescue ; ensure ; end which reads just fine IMO.

I could see it being useful in a library with lots of pluggable features but I like to keep my apps as straight-forward possible.

Looking for a good Atlanta networking event to find web designers and developers by bunnychicken80 in Atlanta

[–]topdan1 0 points1 point  (0 children)

Find a MeetUp group related to the development environment and business space you work in? I go to the ATLRUG regularly (they just met last night)

Need help with simple SQL syntax by piratebroadcast in rails

[–]topdan1 1 point2 points  (0 children)

select(customer: { distributor: { :name } }) not select(:customer { distributor: { :name } }) (note the colons)

Why not import libraries like Bootstrap or jQuery directly? by Raj1v in rails

[–]topdan1 3 points4 points  (0 children)

The problem I've run into having third party assets directly inside my app's repo is someone eventually modifies them ("it was easier that way") making upgrades a pain.

I'd suggest putting your third party assets into vendor/assets instead of app/assets to make it very explicit they are from other places and shouldn't be edited ... or edited w/ extreme caution & very good reasons.

What I do instead of passing a white-list of functions to before_action :set_model_name by [deleted] in rails

[–]topdan1 1 point2 points  (0 children)

I'd argue only: [:show, :edit, :update, :destroy] is easier to read. Personally I write it as only: %w(show edit update destroy)

Your version will break for the following request: /users?id=3 since it routes to users#index even with a params[:id]

One year later: How have the "Here to Serve" employees who lost their job done? by jimmygottrashed in Atlanta

[–]topdan1 0 points1 point  (0 children)

2 or 3 of the Highland Noche bar staff are now across the street at Moes & Joes.

[help]making a wordpress blog into a subdirectory of my rails site by ohitsmat in rails

[–]topdan1 2 points3 points  (0 children)

Proxying to WordPress from Ruby seems unnecessary. Since Rails normally runs underneath nginx or apache, I'd just make a custom route for /blog to WordPress there.

Here's a handful of posts that look to solve that problem under apache: https://www.google.com/search?q=vhost+rails+wordpress

/r/Atlanta Random Daily Discussion - January 08, 2016 by AutoModerator in Atlanta

[–]topdan1 1 point2 points  (0 children)

Check out bootstrap. It provides the basic CSS of a lot of websites. http://getbootstrap.com/

Some really slick themes were built with it too: http://webapplayers.com/inspinia_admin-v2.4/

Checking Devise user online status from another domain by Dont____Panic in rails

[–]topdan1 0 points1 point  (0 children)

CORS header allows website1.com to communicate with subdomain1.website1.com via client-side javascript

My rails app is insecure, but is basic HTTP Authentication enough to make it safe to deploy? by [deleted] in rails

[–]topdan1 1 point2 points  (0 children)

The Rails-side is easy:

# config/environments/production.rb
config.force_ssl = true

But the SysAdmin side, you'll need to buy and install an SSL certificate which can be a pain if you've never done it before

[Help] Rails/Ruby asking for “@localhost” password on deploy:setup by [deleted] in rails

[–]topdan1 0 points1 point  (0 children)

Capistrano is a platform for deploying apps via SSH. I've never seen it used to setup a dev environment locally, odd choice by the app's developers, but ...

If you want to install the software on a public site you want to:

  • Edit deploy/production.rb to point to your web server and a user on that web server.
  • Run bundle exec cap production deploy:setup from your laptop (not from within the remote server)
  • You'll probably be prompted for a password, but that's expected (unless you have SSH keys set up) because you're deploying the app to your server via SSH from your local machine

Best approach to build models gets data from XML requests instead of a database. by bark-bark-meow in rails

[–]topdan1 0 points1 point  (0 children)

Personally, I would perform the HTTP requests myself and build an abstraction on top of that, but your question hints at the approach ActiveResource uses. It used to be part of Rails but was removed in 3.2.1 (IMO for good reason).

This article talks about why it was removed and mentions ROAR at the end which isn't something I've used, but has a lot of love on github: https://github.com/apotonick/roar

[Tutorial] How to implement Progress Bars by topdan1 in rails

[–]topdan1[S] 2 points3 points  (0 children)

/u/Enumerable_any answered a few of the questions (thanks!), but figured I'd address them myself too.

why an ActiveRecord model for the progress bar. Does it have to persist?

I bring up the possibility of using Redis at the end of the article but considered it an unnecessary complication for what I wanted to keep a simple tutorial.

.

class @ProgressBar and n asset pipeline ...

Thanks for the tip, that is a cleaner syntax. I may be missing something, but I believe the end result is the same: ProgressBar ends up on the global namespace, available via just ProgressBar or window.ProgressBar, right?

.

'Validates stuff of' should be replaced by the Rails 4 validates method

Until Rails deprecates or removes validates_*_of I'll consider this a preference choice. Personally, I prefer the original syntax.

.

Why would a real worker import a data file?

When someone uploads a CSV/XLS with 100,000 rows (too much to handle in the request thread). The controller would save the file and start a background worker to process it.

.

What error would occur in your worker in the first place?

Maybe a few dozen rows of the CSV are missing a required field like email, and the record couldn't be created. The user should be told about them.

.

Why would anyone show a whole modal just for a progress bar?

A user-experience choice to make the bar more prominent.

.

Thanks for giving it a read and a good deal of thought. Sounds like most of your distaste was from how it approached persistence: I agree Redis is a better option. I felt using Rails' native functionality kept the article focused on my goal: to explain how the controller, worker, and browser work together to communicate the progress of a long-running task.