Activity
Excellent, cheers. Good time for me to dive into Simulus then! 😀
Right, Javascript does sound like the better route. Would you hijack the form submit and set the values there? Or would you respond to changes on the radio button inputs as they happen then let the form submit normally?
I have a spectrum
boolean column and a spectrum_color
string column and I'd like to display the options to user as shown in this image. I'm using Tailwind CSS and the Jumpstart Pro Rails template so the visual side is easy, just not sure what form helpers to use to get the values from 3 radio buttons to fill one boolean field and a string field.
EDIT: can't get an image to display in this post. Here's a link: https://wmd.d.pr/AMZFsu
Thanks Chris. I found your video on this right after I posted. https://gorails.com/episodes/preferences-settings-with-activerecord-store
Looking at the typed_store gem now 👍 https://github.com/byroot/activerecord-typedstore
I've got a Video model that represents a video created by the user. During creation of a video a couple of filters with different options can be applied to the video. Currently only 2 but I'll be adding more filters soon.
Would this be a good case for storing the filter options in the database as a single JSON column in the databse (Postgres)?
At first I thought of adding boolean and string/integer columns for each filter (and filter option) but even with just 2 filters this gets pretty verbose:
spectrum: boolean => true/false
spectrum_color: string => white/black
spectrum_width: string => thin/think
spin: boolean => true/false
spin_radius: integer => 200/400/800
Seems much better to store this as a JSON object. Any gotchas I should look out for?
Tips for updating Ruby versios? Is there somewhere to look for human-readable changes made between Ruby versions?
I've looked at the Github diffs between Ruby versions which is fine but it's not very readable and can take a long time to parse: https://github.com/ruby/ruby/compare/v2_6_3...v2_6_4
Posted in Grandfathering
By the way, I can attest to the GoRails old plans because I was on the $9/month plan back in 2014 but like a fool I canceled a couple of years later only to resubscribe recently at $19/month! Doink! 😀
Posted in Grandfathering
I have the same situation with klippr.co - it's free to use at the moment but I plan to add a paid plan as I introduce new features.
The app allows users to create short videos from music tracks. I'm considering two ways to transition to paid: [1] let the free users stay on the free plan but they don't get any of the new features, only paid users get those, or [2] let the free users have all the new features but they have a watermark on their videos and can remove the watermark by subscribing.
Alternatively I might do similar to what you're doing - let all the existing free users stay free and get all the features but remove the free plan from the site so all new users must subscribe to a paid plan.
Lots to think about! 😀
Posted in Jumpstart
Although it might not handle the marketplace features you need right now I can higly recommend Jumpstart Pro for the time it'll save in other areas - users, teams, authentication, social login, announcements, emails, user impersonation, and a great CSS base design 👍
Posted in Grandfathering
We've done similar in one of our apps. You can end up in a bit of a mess in Stripe if you're not careful about naming.
For instance, we had small
, medium
and large
plans but I since learned to affix the price to the plan ID so that when the price changes it's still obvious which is which. So now we have small-49
, medium-99
and large-199
.
If we change prices in the future I can just created another set of plans like small-69
, medium-129
and large-249
and leave the existing plans there. Easy!
Posted in Streaming remote files to S3 🤔
For each user request I need to save two remote files to AWS S3. I have the remote URLs of each - one image JPG ~100KB and one audio MP3 ~1.5MB.
I know I can do this by downloading each file to temp
then uploading to S3 using the aws-sdk
gem. However I'm concerned about performance. The files aren't exactly huge but if I'm doing this often enough will it cause an IO bottleneck on my server?
Has anyone done this with streaming? There must be a way to open the remote file as a stream and send that stream direct to S3 without it being saved on my server disk? I assume this would all happen in memory. In fact, is that any less of a bottleneck than saving to temp
?
Confused! Help! 😂
Does this help? https://github.com/influitive/apartment/issues/447
Posted in How to model these relations in Rails
Have you looked at Multiple Table Inheritance? Seems like it might work.
This gem makes it really easy: https://github.com/krautcomputing/active_record-acts_as
I run my local dev site on ngrok and the webpack-dev-server spits out errors to the console on a regular basis:
GET https://localhost:3035/sockjs-node/info?t=1566173800826 net::ERR_CERT_AUTHORITY_INVALID @ sockjs.js:1795
[WDS] Disconnected!
Any ideas what I need to change to stop these errors appearing? Nothing I've tried so far has worked. Or do I need to make choice between using webpacker and ngrok?
Got this working by parsing and opening the URL with URI.parse
:
def video_email
@user = params[:user]
@video_url = params[:video_url]
attachments['video.mp4'] = File.read(URI.parse(@video_url).open)
mail(to: @user.email, subject: 'Your video is attached!')
end
Not sure why it wasn't working with a regular string. The OpenURI docs seem to suggest a string will work.
No, this is a video file that I'm generating in a function outside of Rails.
Eventually I'll be pulling the function into Rails so the S3 file will be easier to handle but for now it's a totally separate file.
I'm using a regular mailer to send text emails and now I want to attach a file stored on S3 to the email. I have the URL of the file and was naively hoping something like this would work:
def video_email
@user = params[:user]
@video_url = params[:video_url]
attachments['video.mp4'] = File.read "https://me.s3.com/video.mp4"
mail(to: @user.email, subject: 'Your video is attached!')
end
But I get an error:
Errno::ENOENT: No such file or directory @ rb_sysopen - "https://me.s3.com/video.mp4"
What's the best way for me to attach a remote file to an outgoing email?
To clarify - the request is being built in the browser with the API token exposed, correct?
And you're concerned about this API token being visible to anyone that pokes around in the browser dev tools?
Seems like this kind of request would be better built server-side so the API token is protected. The website would send the contents of the hash back to the server then the server would build the full requests and send it to your API.
But aybe you don't have control over the client side of things?
Posted in Need a hand with associations
Can a user be both a regular user and the ower of an account at the same time?