Activity
Not with Apartment since they're in separate schemas. If you do row-based multitenancy you can. Check out acts_as_tenant. That's what we use for JumpstartRails.com and it's a lot more flexible and scales better.
Posted in Adding Javascript to Rails 6
Webpacker doesn't make require available in the browser window, so you have to set that explicitly.
window.toastr = require('toastr')
Working example here for you: https://github.com/excid3/rails_toastr_example
Posted in Adding Javascript to Rails 6
Example code I forgot to paste:
def toastr_flash
flash.each_with_object([]) do |(type, message), flash_messages|
type = 'success' if type == 'notice'
type = 'error' if type == 'alert'
text = <<~EOF
<script>
document.addEventListener("turbolinks:load", function() {
toastr.#{type}('#{message}', '', { closeButton: true, progressBar: true })
});
</script>
EOF
flash_messages << text.html_safe if message
end.join("\n").html_safe
end
Posted in Adding Javascript to Rails 6
Hey Tom,
That would be giving you the error because Javascript with inline script tags (that your helper is generating) are executed immediately. It does not wait for your webpacker Javascript to finish loading toastr before it runs. Hence the error.
You will want to wrap your code in a turbolinks:load event so that it waits until Turbolinks is ready and all your JS is loaded before it executes.
Posted in Rails view_components
Yes! I've been meaning to get to that for a long time. ViewComponent is awesome.
Posted in Adding Javascript to Rails 6
Hey Tom,
You'll have to share what you've got so we can help. If you can push up a repo to github, that would be most helpful. Otherwise just post your steps to reproduce the issue and we'll get you sorted. 👍
Posted in URL Based multi tenancy
It's pretty simple and the only things that would affect it are possibly major Rails versions, so there aren't many changes to be made to it.
Posted in URL Based multi tenancy
@Howard OLeary, if you want schema based multitenancy, sure. It's still the best bet for that.
I more often do row-based multitenancy. That's what we do in the JumpstartRails.com template. The ActsAsTenant gem is pretty good for that.
Posted in Searching and partial keyword matches
Probably need to do some more work with pgsearch. 👍
Weird, you'd think they'd prompt for the username / password!
RSS is working just fine for me. What do you mean it no longer works?
Hey Nelson,
You should be able to listen to the change
event on the file field. That fires anytime the input value changes. Use that to fire off the form submit.
Posted in Question about twitter clone
Hey Rick,
Absolutely. If you can imagine it, you can build it. For following hashtags, you'd want to create a model for the Hashtag and then very similar to following users, you'd create a model to join the two records. I'd call it UserHashtag or something and just belongs_to :user
and belongs_to :hashtag
Posted in New website design!
Oh simply because that's what TailwindUI was using and I wanted to ship the site instead of porting their examples to Stimulus. I forgot I still need to convert those!
Posted in Gem for making user groups
Typically I just create a model called Group and a model called GroupUser that keeps track of which user is in which groups.
No gems for it that I know of since everyone tends to implement it differently.
Pundit is great for handling permissions and Devise is great for authentication pieces. The Group and GroupUser models will let you connect the two.
Hey Camilla,
I almost always use the Devise wiki page to not require the current password to update their account. That would make it so the user wouldn't have to know their password to update.
And this would make for a fantastic screencast... 😎
One trick I like is using signed GlobalIDs. This way you can reference any model. Your form could list all the guests and employees and submit their SGID over to the booking to be transformed to the proper record.
They must be signed global IDs to prevent tampering though.
Definitely looks like a good solution if you can't use Javascript. No Javascript is sure going to cause a lot of frustrations for every other feature.
Generally for staging, you can just deploy the app to a single server to save money compared to the production fully load balanced cluster.