Save 36% for Black Friday! Learn more

Tim Dowling


2,740 Experience
9 Lessons Completed
2 Questions Solved


I have a dynamic form im using to create 'sections' within a checklist with one field of 'title' - this also dynamically creates new tabs. I then want to use that input to re name the title of the tab and tab panel. I'm using data-targets and a stimulus controller to do this and it works beautifully, if I only create one section, but any more than one section and it doesn't rename anything. Is there something I can use to pass a unique identifier with the dynamic inputs to use elsewhere?

Hi Samantha,

I've used and adjusted the tabs from chris' stimulusjs-components to make my own wizard form. You can't currently target a tab using a href/id but this is something Chris will consider adding (i will add a issue for this). Not sure if this helps...

Posted in Richtext with Nested Attributes in form

This may have been covered but i've got a form with a nested attribute, which I want to include a rich text form with trix/action text. When submitting the form rails all of a sudden ignores the "fields_for" and tries to associate the attribute to the parent record. It works fine with a normal text_area. Has anyone been able to find a fix?

Posted in Searchkick - Searching Polymorphic Associations

I have an activity feed (thanks Chris for the lesson) and I would like my users to be able to search the feed for search terms. The activity is created on a nested record. Is there a way to search my using the dynamic polymorphic type to find the model? Maybe by defining the search data?

Ok, just solved my own problem. For anyone else wanting to turn radio buttons into actual buttons using CSS there's a 'focus-within' class used to target child elements. I'll probably move away from 'buttons' and use a custom card but here's a solution, just wrap it in a div within the collection block.

<%= form.collection_radio_buttons :event_type_id, EventType.all, :id, :event_type do |b| %>
div class="btn btn-primary text-white checked:bg-white focus-within:bg-white">
<%= b.radio_button class: "opacity-0" %>
<%= b.label class: "" %>

<% end %>

I've been able to use Tailwind to change my radio buttons into normal buttons.

changing the background on 'hover' works, same with 'active' (on click) but there's no setting for 'checked'. Has anyone had any luck building a custom class variant for 'checked' ??

Posted in Acts_As_Tentant User have access to many tenants

Thanks @chris. I was using Rails API and would have had to pass the tenant into the JWT which wasn't obvious and created complexity. I have bought a jumpstart license and have already built 1.5 modules in 3 days on what took me 1.5 months last time. I'm throwing away 6 months of code but gaining huge amounts of productivity.

It would be great to get a video on creating an autocomplete search with stimulus if you're short of ideas :)

Posted in Rails 6 autocomplete with add new

Did you ever find a solution for this Alex? I'm very new to stimulus and I would love to know how to do autocomplete with it too :)

Posted in Acts_As_Tentant User have access to many tenants

@chris you already built this with jumpstart? Can i ask if you're storing the tenant in the session?

Posted in Acts_As_Tentant User have access to many tenants

Ok I've updated the issue. i think what i posted would work for a normal rails MVC app by storing the tenant in the session. However with a rails API only app it's a no go so Im a little stuck.

Posted in Acts_As_Tentant User have access to many tenants

Thanks Chris, based on what you're saying would we need to change the gem? My implementation for finding a tenant:

def find_current_tenant
if user_signed_in?
account = current_user.accounts.first
puts "current tenant: #{ActsAsTenant.current_tenant.inspect}"

So simply trying to return the first tenant created for that user. But then when im trying to access a record im getting a "NoMethodError (undefined method `last' for #Account:0x00007fffe9a93990):" error....

Posted in Acts_As_Tentant User have access to many tenants

I've just created this enhancement for acts_as_tenant and wondering if anyone else would find this useful -

Currently acts_as_tenant expects a single object rather than being able to access all tenants/accounts for a user. If a user can have many accounts then they jump between accounts. Use case could be a business advisor with many clients and they need to process 'X' in different client accounts. Keen for thoughts on this...

Posted in Actiontext used for templates/placeholders

I've got a little business finance management app and I'd love my users to be able to create their own custom templates for quotes/invoices. The way all my competitors do it is through merge fields with DOCX templates which is fiddly for the user.

I just watched Chris' railsconf talk on action text and creating custom attachments and was wondering whether instead of attaching a record you could leave a placeholder where i could pass the record in via json and it renders in the template? I've only seen examples where an actual record is retrieved so wondering if this can be done? Alternatively would the better way be to use a normal wysiwyg editor and create a placeholder for the record attributes that gets populated? Keen for all the ideas!

Posted in PAGY with Rails API Only

Perfect, thanks for the response Chris. It'll be sinmple to write a ?page=X +1 type method as the page comes in the header of the response. I could also utlise the 'link' from the header.... I'll have a play :)

Posted in PAGY with Rails API Only

Hi All,

I've built a Rails API and have a separate Nuxt/Vue app for my front end. Looking to add server side pagination with Pagy and was wondering how i best to call the next 'X' number of results.

Pagy is working fine and giving me my first 20 records, but to call the next 20 I'm a little confused. Do i need to specify the URL from the front end as in 'localhost:3000/contacts?page=2' and send that, or can i pass some params like [:next] as mentioned in the docs. Has anyone had success with this or has an example?



Posted in Multi tenancy for one type of user

No worries at all, let me know if you have any questions with it :)

Posted in Multi tenancy for one type of user

I have just launched my multitenancy app using Milia Gem which is fantastic and uses primary keys rather than subdomains

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.