Ivan Raszl

Joined

4,170 Experience
37 Lessons Completed
0 Questions Solved

Activity

Posted in How to use Uppy with ActiveStorage Discussion

Thank you for doing this video. It's great.

Can you give pointers to how to implement multiple file upload fields on a single form? For example, if I wanted users to upload multiple images in one field and multiple videos in another field?

Posted in Install Bootstrap with Webpack with Rails 6 Beta

Locally it works, but when I push the code to Heroku the assets are not precompiled. No CSS or JS present apparently.

Do I need to add yarn add [email protected] jquery popper.js to my Procfile or somewhere when deploying to Heroku?

Posted in How to handle long-running external services?

Some ideas to consider. Can you:

  • use cron (or scheduler) on Heroku to kick off the job regularly so the long running service is not taking so long?
  • break the long-running service up into smaller pieces?
  • dedicate a worker just for this long-running service so you don't mind it being tied up?
  • configure the external service so it pings you when the job is done?

Posted in How to write System Tests in Rails Discussion

Great lesson.

At 11:50 you show a bootstrap modal for confirmations. How do you build that to replace the browser modal that is by default generated for a typical delete button?

Posted in How to use Devise Test Helpers Discussion

Apparently, the industry is moving towards minitest. It makes sense because the strength of Rails is that you can develop faster if you use the standard tools and ways. Thus, generally using built in tools, like minitest, action cable, active storage, etc. is a good long term strategy.

Posted in Multiple File Uploads with a nice JS interface?

I don't have an answer for you, but I wonder why is it a problem that all the files are in a single folder. You database will pick the right file for you anyway. You're using a file server for your files, right? So the uploaded files are not mixed up with your Ruby files. Do you ever have to ftp into your file server to find a specific file?

In case somebody needs it. Here are the steps to make it work.

  1. Set up your S3 bucket. Use this CORS on the bucket: https://github.com/basecamp/trix/issues/128#issuecomment-523545259
  2. Allow List Objects, and Write Objects for the public. Not exactly safe, but it allows you to upload without presigning.
  3. Optionally add Cloudfront and allow POST.
  4. Take note of your Cloudfront URL.
  5. Add this to your https://trix-editor.org/js/attachments.js application.js
  6. Change the HOST to your cloudfront URL.

Posted in Rails 6.0 + Heroku + Active Storage + VIPS

Thank you!

I'll try to remove what you are unsure about and report back. What's wrong with that line?

I was able to fix the CSS/JS issue. I just had to comment out these in production.rb, probably because in Rails 6.0 things differently. Need to learn about this...

# config.assets.js_compressor = Uglifier.new(harmony: true)
# config.assets.css_compressor = :sass

Posted in Rails 6.0 + Heroku + Active Storage + VIPS

Thank you! I'm getting closer to a solution.

Buildpacks:

heroku buildpacks:add --index 1 heroku-community/apt
heroku buildpacks:add --index 2 https://github.com/brandoncc/heroku-buildpack-vips.git
heroku buildpacks:add --index 3 heroku/nodejs
heroku buildpacks:add --index 4 heroku/ruby

Add Aptfile to root with the following content:

libglib2.0-0
libglib2.0-dev
libpoppler-glib8

Add to Gemfile:
gem 'image_processing', '~> 1.2'

Example call from views:
post.image.variant(resize_to_fill: [500, 250, linear: true]).processed

The VIPS part now works with Heroku, but I'm still struggling with some bug. For some reason my CSS and JS files are not loading on Heroku, but they are loading fine locally.

How do I integrate Trix with ActiveStorage and AWS S3? Thank you!

Posted in Rails 6.0 + Heroku + Active Storage + VIPS

Thanks Chris. I was meaning to try out Hatchbox.

Posted in Rails 6.0 + Heroku + Active Storage + VIPS

VIPS is a 3x faster and 10x less memory hungry image processor that is now available for Active Storage in Rails 6.0. Unfortunately By default Heroku doesn't support VIPS. Do you know of a working buildpack you tested that has VIPS support?

What do you expect the output to be? A web page? If yes, you need to:

  • Put all of this code into a controller, and instead of 'puts', assign the results to an array that contains all the data you want to output.
  • Create a view that displays the content of your array.

Great episode. I never knew you can add an array for columns into an index!

Posted in Scheduling Posts Discussion

To fix the Turbolinks issue you could put your js into a wrapper like this:

$(document).on("turbolinks:load", function() {
  # your javascript goes here...
});

What do you guys think?

Posted in Webpack assets doesn't work after deployment

Do you want to post more details, like what error you're getting or where you're hosting?

Consider using websockets, it would allow you to feed the refreshed data immediately, not wait for a minute potentially, which is kinda long when you're talking about real-time.

Read more here if your app is Rails: https://guides.rubyonrails.org/action_cable_overview.html

Posted in Need a hand with associations

Thanks for explaining.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.