Chris Oliver

Joined

292,300 Experience
93 Lessons Completed
295 Questions Solved

Activity

Like I mentioned before, CF is a proxy so it passes the requests to Rails. Rails serves up files just like it always does. Nothing special.

That's the cool part. When you configure the backend, it will accept all requests and then ask your app (the backend) for the files and send them back. It saves them in the CDN so that next request, it doesn't have to ask your app again and can serve it up immediately. It just sits in between the user and the app as a proxy.

Uploaded it to YouTube so you could see it early. 😎

https://www.youtube.com/watch?v=5KuTzT_MWoM

Recorded a video on it. I'll be publishing it in the next week or two. 👍

I may have accidentally missed a little bit of that as I was trying to prepare for the episode. 😬

You can usually just call the sanitize method and that'll do what you need.

Yep! Push notifications would be an API call (similar to Slack, Twilio, and Vonage are). 👍

Well, notifications are a complicated subject. Basic ones like sending an email are easy, but this is a full-featured notification system like you'd see on Facebook or Twitter. I'll talk more about it and show a very basic use case of Noticed soon.

Posted in Thousand separator and Number formating

Also for the frontend, I usually build my own helpers to generate the two fields for me. Saves a lot of time and I can just make a small change to each field with a find & replace to call the new helper instead of having to edit each one.

This would make a great screencast talking about the tradeoffs of both approaches.

Posted in Thousand separator and Number formating

You can definitely strip out the commas or periods when the user submits the data if you want by overriding the setter methods. That would let any value be submitted and cleaned up before storing it in the model.

def population=(value)
  super(value.gsub(/[.,]/, '')
end

Something like that should do the trick.

Since it's just formatting, it's usually best if that just happens on the client side. That becomes even more useful in other languages that might use a period as thousands separators instead of commas. They can change their locale and the backend data would not have to change for that. Plus, the backend doesn't have to worry about modifying the formatting, just validating it.

Either way will probably work fine though.

Posted in Thousand separator and Number formating

Fake form fields can accomplish what you want.

You can use formatting in the visible form field, but convert to the number in a hidden field. The visible field is not given a name field which means the browser does not submit them to the server.

The hidden field will be what's submitted to the server. You'll use some Javascript to make sure the field continues formatting as the user changes the value.

This is how date selectors that use a Javascript calendar popup work a lot of times. Same for credit card fields. 👍

Make sense?

Posted in Thousand separator and Number formating

Rails has several helpers for numbers.

number_with_delimiter(population) # outputs 422,334
number_with_precision
number_to_currency

All part of the NumberHelper: https://api.rubyonrails.org/classes/ActionView/Helpers/NumberHelper.html

Numbers should always be saved without formatting in the database and then you'll use a helper like the above to format it.

Hey Marlon!

We're using the acts_as_tenant gem in JumpstartRails.com for row-level multitenancy. It works pretty well and will automatically set your tenant ID when querying and saving records. You end up building your app like a regular app that way which is nice.

I wouldn't recommend Apartment anymore because it's not row-level tenancy. It's far more common to see row-level being used.

It's not intended to be a full WYSIWYG which is what you're after. I know several people like using https://imperavi.com Article and Redactor and they're really well made.

Posted in A Look Into Routing Discussion

He loves running around and being noise when I'm trying to record. 😺

Posted in Active-storage creating/uploading folder

I would say, don't think of it as folders on S3 or the file server. Use database records to group and organize them in your app. They don't have to exactly mirror the files on disk.

Posted in Render before action completes

Julian Rubisch put together a gem that makes this easy: https://github.com/julianrubisch/futurism

💪 This is awesome Nate! This is a great opportunity if anyone's interested in getting a bit of experience working with a team.

I said that and decided to look at the Pay gem and think I figured it out.

The Rakefile in that gem loads the Rakefile from the dummy app. That makes total sense.

APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)