John Athayde

Joined

6,790 Experience
66 Lessons Completed
0 Questions Solved

Activity

Posted in What's New In Ruby 3.3 Discussion

And ruby-build itself now has 3.3 with ruby-build--20231225 (working with rbenv, not sure on asdf)

Working on this and I have a variation on the login that does login OR email per the Devise wiki (https://github.com/heartcombo/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address) and it has something similar at the bottom, but that code seems outdated and isn't working. So I have email, login , and a virtual attribute of userlogin setup with attr_accessor. When passing to the pre_otp check, it errors that userlogin isn't a column, which is correct. But the form works when not split.

(I did change Pro to Proc in the wiki example as Pro was unknown; That then results in a undefined method 'where' for Proc:Class error, so the issue may be there as opposed to something else)

Any ideas?

Posted in Two Factor Authentication With Devise Discussion

Are you getting this on the delete? There is no show method for that controller. Check yoru code in _two_factor.html.erb. Do you have the method: :post or method: :delete on the items?

Posted in Dynamic Nested Forms with Stimulus JS Discussion

Would there be a way to order the objects returned on edit? For example, each item I have has a date, quantity, and notes field. How would I sort by date?

Posted in Carrierwave Backgrounder in Rails 5.2?

I have an image uploader on a form, and images upload fine without the background processing. Since moving to Heroku, the larger source images often time out, so I'm looking to move this to a background job. In doing so, I looked at carrierwave_backgrounder since it seemed to cover what I need.

I've found a fork of carrierwave_backgrounder and I've forked it to my own repo. To get it working in 5.2, the author said he had to hardcode the path (https://github.com/lardawge/carrierwave_backgrounder/issues/282, https://github.com/lardawge/carrierwave_backgrounder/issues/280)

This fails on store_in_background. Running just process_in_background yields locally processed images in development, but they are not uploaded to S3.

The field in quesiton is issue.image and here's how it's mounted in issue.rb:

# Image attachment via Carrierwave
  mount_uploader :image, ImageUploader
  process_in_background :image
  store_in_background :image
  attr_accessor :image_cache

Here's the output error:

2019-02-24T01:05:33.168Z 43666 TID-oxnydp4bq CarrierWave::Workers::StoreAsset JID-83163770b014d37186118cf9 INFO: start
2019-02-24T01:05:33.545Z 43666 TID-oxnydp4bq CarrierWave::Workers::StoreAsset JID-83163770b014d37186118cf9 INFO: fail: 0.377 sec
2019-02-24T01:05:33.545Z 43666 TID-oxnydp4bq WARN: {"context":"Job raised exception","job":{"class":"CarrierWave::Workers::StoreAsset","args":["Issue","6355","image"],"queue":"carrierwave","retry":true,"jid":"83163770b014d37186118cf9","created_at":1550970333.167957,"enqueued_at":1550970333.168011},"jobstr":"{\"class\":\"CarrierWave::Workers::StoreAsset\",\"args\":[\"Issue\",\"6355\",\"image\"],\"queue\":\"carrierwave\",\"retry\":true,\"jid\":\"83163770b014d37186118cf9\",\"created_at\":1550970333.167957,\"enqueued_at\":1550970333.168011}"}
2019-02-24T01:05:33.545Z 43666 TID-oxnydp4bq WARN: TypeError: no implicit conversion of nil into String
2019-02-24T01:05:33.545Z 43666 TID-oxnydp4bq WARN: /Users/jathayde/Development/Meticulous/carrierwave_backgrounder/lib/backgrounder/workers/store_asset_mixin.rb:40:in `join'

and here's the relevant method from my store_asset_mixin.rb method from my local version of the gem. The line 40 mentioned in the error is the one that starts with @tmp_directory:

      def store_directories(record)
        asset, asset_tmp = record.send(:"#{column}"), record.send(:"#{column}_tmp")
        cache_directory  = File.expand_path(asset.cache_dir, asset.root)
        # @cache_path      = File.join(cache_directory, asset_tmp)
        # # XXX Hardcoded our path here... not ideal..
        @cache_path      = open("https://patchvault.s3.amazonaws.com/uploads/tmp/#{asset_tmp}")
        @tmp_directory   = File.join(cache_directory, asset_tmp.split("/").first)
      end

So asset_tmp is "", yet asset but I have no idea why. Stepping thorugh it with debugger it seems that the record.image is present, but the record.image_tmp column is simply empty.

Posted in Comments With Polymorphic Associations Discussion

I'd love to see this as well. Tried briefly and was unsuccessful.

Posted in How To Use Turbolinks clearCache() Discussion

Is there anyway to invoke this when moving between layouts? I often (but not always) need a screen refresh when moving from application.html.erb to admin.html.erb (different layout and stylesheets)

Posted in Best practices for self-referential habtm setup?

Anyone have any thoughts on this?
Basic concept:
Patch collecting app. There are issuing entities in the system that issue patches. That model is "issues". In many cases, these are difficult to tell apart. So I want to add a similar issues functionality that would be self referential on the issues table. 

When creating this, it should go both ways. If patch 1 looks like patch 5, then patch 5 looks like patch 1. Do I need to do double entry or would two indexes (issue_id, similar_issue_id) work? 

This can often be many different issues, so would this make more sense to have issue_id and then have similar_issues_ids as a JSON or other multiple value store?

Posted in Decorators with the Draper Gem Discussion

How do you handle something where you're using a foreign key, for example a Commentable concern. Comment has a user as commenter. The User class method works fine, but is there a catch all way to address these or do I need to set up instances in the relative controller methods?

Posted in Comments With Polymorphic Associations Discussion

+1 on the suggestion. Daniel's link is helpful, but I'm getting caught up on the polymorphic_url generation to use the _comment partial as a shared file between mutliple models.