Activity
Posted in Do you measure your app's uptime?
Pretty much has to be an external service, since you want it running independently of your app. And, so you don't have to also monitor and run your own uptime monitoring, most people just pay for something.
I like and recommend HoneyBadger.io will do uptime checks, check-ins, and error monitoring all-in-one. Nice to have those features together in the same app rather than paying for multiple things. They have a free solo-dev option that comes in handy.
You've also got tools like Pingdom that will do performance / uptime. Lots of other options out there too.
Posted in SQLite3::SQLException: no such column:
Since it says your comments table has no post_id
column, you should check your migrations and make sure you didn't forget to add the column. :)
Posted in Grandfathering
Just to re-iterate here, we had a brief discussion of this on Twitter.
For GoRails, I simply removed links to the old plans when pricing changed. I created the new plans in Stripe and linked to them on the pricing page in the app. Existing customers stayed on the old plans and new customers could only subscribe to the new plans.
Everyone gets grandfathered in that way, and any special cases where I might need to set someone up on the old grandfathered plan can be done manually in the backend.
Posted in Jumpstart
The payments library we're using for Jumpstart Pro, Pay, doesn't handle marketplaces right now. You'd need to implement Stripe Connect yourself instead.
At some point in the future, we'd like to support that, but we're upgrading everything to be SCA compatible first. Then we will probably look into marketplaces, but since we support both Stripe and Braintree, that's a bit harder to make them both work similarly, especially for marketplaces.
There are a couple options called discard_day
and discard_month
that you could set to true to hide them and only display the year. All the options are listed here: https://api.rubyonrails.org/v5.2.1/classes/ActionView/Helpers/DateHelper.html#method-i-date_select
I would add a validation to the TeamMember for that.
class TeamMember
belongs_to :team
validate :team_has_owner
def team_has_owner
error.add(:base, "Team must have at least one owner.") unless team.team_members.where(role: :owner).exists?
end
end
Posted in How can I create a user specfic page?
Hey Louie, you may need to explain more of what you're trying to build. Typically you don't want to have multiple Devise models, just a single User with roles instead. It's much easier to work with.
I don't think a whole lot has changed. They have instructions for using it with Webpacker now, but it seems mostly the same to me. Are you talking about anything specific?
RestClient is pretty good for accessing an external API, although sometimes people have built an wrapper around the API to make it easier to work with. You might check rubygems.org to see if you can find an API wrapper gem.
Then once you get the information back from the API, you probably want to save it in your database.
And to render it in Open Street Maps or something similar, you'd use their Javascript APIs to load in the routes.
https://wiki.openstreetmap.org/wiki/Routing
I'm doing this in a table in the form:
<% I18n.t('date.day_names').each_with_index do |day, wday| %>
<td class="day">
<div class="form-group">
<%= form.select :"#{day.downcase}_opens_at", time_select_options, label: "Open Time", include_blank: "Closed" %>
</div>
<div class="form-group">
<%= form.select :"#{day.downcase}_closes_at", time_select_options, label: "Close Time", include_blank: "Closed" %>
</div>
</td>
<% end %>
That creates selects for each time of day. I have this helper for those times.
module ApplicationHelper
def time_select_options(step=15)
tod = Tod::TimeOfDay.new 0
times = []
96.times do
times << [tod.strftime("%l:%M %P"), tod]
tod = tod + step.minutes
end
times
end
Then it gets serialized by Time Of Day gem in the model.
class Business
serialize :sunday_opens_at, Tod::TimeOfDay
serialize :monday_opens_at, Tod::TimeOfDay
serialize :tuesday_opens_at, Tod::TimeOfDay
serialize :wednesday_opens_at, Tod::TimeOfDay
serialize :thursday_opens_at, Tod::TimeOfDay
serialize :friday_opens_at, Tod::TimeOfDay
serialize :saturday_opens_at, Tod::TimeOfDay
end
Posted in How to model these relations in Rails
Here's some quick psuedo code:
class Fleet
has_many :cars
has_many :trucks
validate :same_type
before_create do
self.fleet_type = "Car" if cars.exists?
self.fleet_type = "Truck" if trucks.exists?
end
private
def same_type
if cars.exists? && trucks.exists?
errors.add(:base, "All items in fleet must be of the same type")
end
end
end
Posted in How to model these relations in Rails
Not built-in. You could set it before_create and check the first child model type and use that, and also validate that they're all the same type.
Posted in How to model these relations in Rails
I would probably just add a fleet_type
column to the fleet that keeps track of which is allowed: Train
Car
, etc. Then you can use it for validation against the associated models to make sure they're of the correct type.
Probably because you're using SSL to access your site over ngrok and your dev server is not. Try using http with ngrok.
Whoops, misread Heroku as Hatchbox. The following would be how you would use VIPS on Hatchbox.io:
sudo apt install -y libvips libvips-dev libvips-tools
Hey Taylor, I just built this for a project actually so I have some timely experience for ya. :)
Postgres has a Time column you can use that doesn't include a date. This works perfect.
The TimeOfDay gem you can use to serialize those time columns into a TimeOfDay object which is a time without a date. That comes in handy since that's what business hours really are.
We decided to setup 14 columns, a start and end time for each day of the week. You could also save 14 attributes to a jsonb column instead of 14 separate columns. Those two approaches would work about the same and you could query against either one.
As for the form, same as usual. You build a select field that selects a time, and submits it. Make sure the attributes are permitted and the TimeOfDay serialization will make sure it gets cast to a time in the database.
I made a little helper to generate a select options from 12am to 11:45pm every 15 minutes to make selecting times easier.
Posted in GoRails Design
Hey Anton! I bought a theme from Bootstrap's store and used that. 👍
Posted in JWT with Devise (App and API)
Oliver, yep. If you login on the web, you'll login with a session cookie. Otherwise you'll hit the API with a token and be logged in only for that request.
Posted in Unable to create the Rails app in WSL
Sounds like permissions issues and seems like other people have experienced that. Try this: https://askubuntu.com/a/1118158
Hmm, good to know. I'm not quite sure why that would be required, but at least you got your problem solved.
I haven't had to do that, but maybe there's something with the way your code is requiring things that makes it need that.