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?
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?
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?
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?
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.
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.
- Set up your S3 bucket. Use this CORS on the bucket: https://github.com/basecamp/trix/issues/128#issuecomment-523545259
- Allow List Objects, and Write Objects for the public. Not exactly safe, but it allows you to upload without presigning.
- Optionally add Cloudfront and allow POST.
- Take note of your Cloudfront URL.
- Add this to your https://trix-editor.org/js/attachments.js application.js
- Change the HOST to your cloudfront URL.
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
Thank you! I'm getting closer to a solution.
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!
Thanks Chris. I was meaning to try out Hatchbox.
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:
What do you guys think?
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.