Aaron Xavier


1,070 Experience
8 Lessons Completed
0 Questions Solved


Posted in Thousand separator and Number formating

IT ABSOLUTELY will be a great ScreenCast. The whole dealing with numbers from front-end and back-end doesn't either exist, or scattered or I haven't found/be satisfied with it. You should absolutely address this issue because let's face it, number fields are very common in many if not all applications and someone needs to lay the proper foundation on how to address it from a user experience to backend handling. Let me put it this way, if you as a developer are creating forms that has number fields, it should have at-least have thousand separators for better user experience, period. (now I sound like Andrew Mason)

Also, thank you again for the advise, I will take the route of creating a helper method, even though filtering in the model seems like the easy route.

Posted in Thousand separator and Number formating

@Chris Oliver it absolutely does. I guess I was avoiding going in that route because now I have to create fake input for each of the fields. My app is pretty big and there are like 90 fields that are number fields (some dollar figures, some decimal, some percentile and so on.)

Yes I can absolutely do that, but I was hoping that at the model level, the model would sanitize all the number fields before inserting. In that way, it doesn't matter what the front-end looks like or if someone is injecting dirty fields, the model would take care of just taking the numbers (and in sanitizing I mean at-least be somewhat intelligent that in 21st century a number field might have commas which is still a valid entry and so I will remove the commas or any currency characters before entering into the database.)

I suppose, I will bite the bullet and go in that route.

Posted in Thousand separator and Number formating

Hi Chris, I know those are great for displaying the numbers in proper format. I was looking for a formatter that works with form field. So when a user is filling up lets say _________________ (3 mile radius population) the form field would automatically thousand separate as he is typing. Which I am using Cleave.js to accomplish that.

"Numbers should always be saved without formatting in the database and then you'll use a helper like the above to format it." I agree and that is the part I am having issues when. When users submit the form that has as number field with comma in them, rails only takes the first few numbers until the comma character. So form submission looks like this:

Processing by Crm::PropertiesController#update as HTML
  Parameters: {"authenticity_token"=>"1s5U4Dtoi6d8ELOdiJ4SOM6N3qn8qgCv9nRfKXWCKcTGOFfHjSb+MgkJ77BPysiy4FOJ6j6AuWWgHSV2cjfN9w==", "property"=>{"property_name"=>"[FILTERED]", "investment_profile_attributes"=>{"deal_stage_id"=>"3", "id"=>"129", "deal_priority_id"=>"3", "three_mile_population"=>"422,334"}, "commit"=>"Update Property", "id"=>"131"}

Then rail updates the record as below:

UPDATE "properties" SET "three_mile_population" = $1, "updated_at" = $2 WHERE "properties"."id" = $3  [["three_mile_population", 422], ["updated_at", "2020-08-24 21:12:48.827993"], ["id", 131]]

Posted in Thousand separator and Number formating

Something as simple as formatting a number in form field with thousand separators and currency symbol is driving me crazy! Something that should be simple to do and more importantly should be part of rails to organically (I mean we in the twenty-first century {does_this_guy_sound_frustred: :true})

I know there are several JS library that I can use for the front-end/form-side. I decided to go with Cleave (https://github.com/nosir/cleave.js) because I didn't wanted a jQuery dependancy.

Form submits: "three_mile_population"=>"422,334" but when rails is updating, it is truncating at the commas

UPDATE "properties" SET "three_mile_population" = $1, "updated_at" = $2 WHERE "properties"."id" = $3  [["three_mile_population", 422], ["updated_at", "2020-08-24 21:12:48.827993"], ["id", 131]]

Yes I can go with a gem like Money. But the idea is I really don't need it because in my case, my values are in Millions and my users don't care for decimal fields for some of these fields (few other fields do have decimal.) I don't feel like loading up my app with another Gem and having to run migration on the database to create additional columns that the gem Money demands.

I tried using https://github.com/rmm5t/strip_attributes to remove any $ commas but that is not working either (not sure why.)

Does anyone else has any better solution for thousand separators. Can StimulusJS cleanup the format before submitting (should that be the route I should take?)

Posted in Active-storage creating/uploading folder

Got it. Two joint tables to files model and folders model, would do it. That makes sense. Thanks!!

Posted in Active-storage creating/uploading folder

Have any of you guys worked on a project where you can upload or create folders inside your active-storage attachment model? In another words or better way of describing, imagine you have a model called “Projects” which has_many_attachments called Projectfiles. But instead of uploading not just files, you would your users to upload/create folders. A mini dropbox for your project.

Are there any gems or does active-storage allow you to add folders?

Chris, a great screencast would be to use the a global Stimulus Js Modal that you can use to render views inside (say show/edit of controller views) This is something that can/should be part of JumpStart pro so that when you are in index page of any controller, a view action pops open Modal and renders the show inside.

Majority of the time, controller's show and edit pages are small enough where they should actually be rendered inside Modal using Stimulus Js. This is a solution I am trying to find from Google, so far no luck.

Your TailwindCSS Stimulus Components Modal is great, but to use it to render other views inside would be more awesome.

Hi Chris, Great tutorial. I noticed that when you go back to edit a page, the map loads the correct location from lat and long, however, it does not place the marker back. It would be confusing for users let's say on a property details page when the page loads, it will zoom to the correct building/area but since the marker for the actual address didn't load, the user won't know which building they are looking at. Instead they are going to be looking at the whole map with other business names and their markers. In summary, when you go back to your edit page (from your screencast) it should load the marker.

Posted in Global Autocomplete Search Discussion


I think I just asked this question today. Exactly what I am trying to do.

I am working on a project and running into issues on how to accomplish this.

  1. I am using Wicked Form steps for better UX. Steps are: a. Upload CSV, b. Confirm Data, c. Finalize/Add to database
  2. Upload CSV is fine, then while looping though the rows of CSV, add the records to an object for later use. CSV.foreach(file.path, headers: true, header_converters: :symbol) do | row | @new_ledger_data << row.to_h end
  3. Step: Confirm Data - Show the table @new_ledger_data ---------- up to this I am done. Step 4 is where the issue is.
  4. Step: Finalize - This is where I would like the @new_ledger_data.each to loop thought and for each row, Create a new record AND** immediately update the view with newly added record to give the user feedback using AJAX, before moving to the next row of the loop.**

I have used the remote: true on my form (when the user hits Finalize) and it submits it goes though the loop and creates the records BUT does not stop in between to update the view. In another words it completes the whole process, then shows the completed table, rather giving feedback to the user with single record at a time.

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.