Activity
Hey Daniel,
There's a concept called OEmbed that was designed to let services define their own embed codes. You just give their site the URL you want to embed and then send you JSON back on how to embed it.
There's a Ruby library for it that is pretty useful: https://github.com/ruby-oembed/ruby-oembed
This is the approach I'm using on Jumpstart Pro to provide embed codes in ActionText.
Posted in RSpec w/capybara vs Mini Test
@sweedledee there's not a lot of good examples out there! I did a lot of the Testing Rails series in Minitest which is a start. The Rails test suite is where I learned a good bit if you feel like digging through the repository.
I bought betterminitest.com to document common use cases and need to start putting that site together!
That was the first thing I did when I added Noticed to JumpstartRails.com :)
Conceptually all you need to do is:
- Add a dropdown for notifications
- Setup notifications to use Database + Websocket delivery methods
- Have Javascript listen to the websocket and insert the notification when a new one is received
- Add the red dot to the HTML
- Remove the red dot when opening the dropdown
If I'm looking for the template from a brand new Rails app, I'll actually open the github repo for Rails and find the template in there.
And I imagine you'd get answers quickest on StackOverflow. I always forget about the Rails discourse. I need to poke around on there more regularly.
Don't forget the GoRails slack if you're a subscriber! There's always people around to help there.
I spent a lot of time just reading source code for Rails and trying to apply those approaches to my own code.
Most of the deep knowledge is just Ruby, not Rails. I should mention, I made a course last year that digs into all these things that I wish I knew about Ruby when I was learning Rails. Explains a lot of approaches that you'll see in gems like Rails. Took me years to learn all this stuff, so I thought it'd be good to put it into a course. Might be worth checking out. https://courses.gorails.com/advanced-ruby-for-rails-devs
Posted in Multiple user types App design
Generally, the easiest is use 1 Devise model and separate models for the type of user. That way everyone uses the same sign in page.
What glitches are you referring to?
Ruby 2.7 and Rails 6.1 are probably the best to go with for now I'd say.
Posted in Go Rails Youtube videos not loading
Strange, the Message Templates video plays fine for me, logged in and incognito. Maybe a browser extension or something blocking it?
Side note, the search is SLOW. I need to fix that.
You can't use include
with a class. Remove that and reference the class directly like so:
class Licencia < ApplicationRecord
validates_with Validators::LapseValidator
end
That should do the trick. 👍
It needs to be namespaced under Validators:
class Validators::LapseValidator < ActiveModel::Validator
Generally, the concerns folder is for modules so it might get confusing in there but it should work.
You could also probably use app/models/validators/my_validator
and include Validators::MyValidator
now that I think about it.
I like this better than app/validators
Any folders in app/
will be autoloaded, so you could create app/validators/my_validator.rb
and include MyValidator
in your model. Rails will autoload that and find it correctly. This is my preferred way of doing things usually.
Or you could put it in lib and require it as well.
Posted in What is Hotwire Strada?
No idea either! DHH said something that you can do 95% of mobile with Turbo and no Strada. Doesn't really explain much, but I'm real curious when it ships!
Posted in Action Mailbox Routes
Add a constraint to your catch-all to ignore the /rails routes. 👍
Posted in Authentication in 2021
I think it's mostly because leaving your user accounts in the hands of a third-party adds a lot of complexity and they'd rather have full control in-app.
Those options can be good options if you need enterprise integrations or you're building static apps though where you don't have a backend that can do it.
Hey Charles,
Time.zone
comes from ActiveSupport, so you'll need to either do this in the Rails console or require "active_support/all"
in your IRB session.
This never became the default in Ruby 3 unfortunately. See: https://bugs.ruby-lang.org/issues/11473#note-53
I don't use it, but I probably should although I'm sure I modify strings like this more often than I realize. It's a pretty great performance improvement when you can use it!
Some more good reading: https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/
Check the readme, we have instructions for that. 👍
You create a password in the credentials (make one up) and then use that password in Sendgrid's webhook URL. That way Rails can verify the POST request came from Sendgrid (and not someone trying to abuse your app).
Posted in Login with Facebook Discussion
Try using ngrok to expose your localhost to the internet. That will give you a public domain and SSL.