Aaron Xavier


2,490 Experience
21 Lessons Completed
0 Questions Solved


It was. Thank you for this 👍

Great episode. I think the best solution to remove an element would be to use a stimulus controller. And this way, it can be re-used easily and we don't have to keep writing the turbo_stream_action_tag. So something as simple as: <span id="saved" data-controller="remove" data-remove-timeout-value="5000">Saved</span> would do it and can be re-used.

Posted in Dynamic Nested Forms with Turbo Discussion

Full Turbo: There is an big problem with this approach. Let's say the task model has a validates :name, presence: true You add two tasks or more and when you submit the form (let's say leaving the name empty) it will come back and show you the error. However, in the next round (meaning again if you hit submit) it removes all the tasks and only keeps 1 task. Basically what is happening is this: When you submit and validation fails and the form is re-rendered, the task id for all the tasks are reset to the 1st task's id. Meaning, all the task will have the very first task's id of Time.now.to_i

Posted in Dynamic Nested Forms with Turbo Discussion

A delete button to remove the nested field or _destory the nested field would be great to add to this tutorial

On the save_with_captcha function you are running the "valid?" in the Hcaptcha.success if-else statement meaning if Hcaptcha.success fails on the else statement - run "valid?" , and if Hcaptcha.success is successful you are calling "save" method. Shouldn't the "valid?" run regardless if Hcaptcha is successful or not? Because Hcaptcha.success might be successful but other validations might fail.

Posted in Noticed Gem - Twilio is not working

Figured out from the debug that in addition to the def message function I also need to have a param[:message] (which is used by twiolio. Somehow I missed that this is a requirement from the docs. :(

NewEnquiryNotification.new(enquiry: @enquiry, message: "#{@enquiry.first_name} just sent an enquiry.").deliver(User.all)

Posted in Noticed Gem - Twilio is not working

Using jumpstartpro. Setup the credentials and verified that they are correct. All other delivery methods work, but I am getting this error for Twilio

Error performing Noticed::DeliveryMethods::Twilio (Job ID: 6a072966-9bce-4abb-8c91-f48a92a81db6) from Sidekiq(default) in 344.18ms: Noticed::ResponseUnsuccessful (Noticed::ResponseUnsuccessful):

No other details as to why. Any idea how I can troubleshoot the issue?

Posted in Autosave Draft Records - Part 1 Discussion

Seems like draftsman is not compatible with Rails 6.

draftsman was resolved to 0.8.0.dev, which depends on
      activerecord (>= 4.2, < 5.3)

Need to find alternative.

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.