Chris Oliver

Joined

290,710 Experience
86 Lessons Completed
298 Questions Solved

Activity

Posted in Phusion Passenger error on Hatchbox

Is there more to the stacktrace? This doesn't look like a complete one.

Posted in How do I resolve this syntax error

Presumably you meant options to be a hash? You used () instead of {}

options = {
  stripe_id: customer.id,
  stripe_subscription_id: subscription.id
}

Doh! You can delete the file and generate new credentials. That's probably the easiest option and then you can save the .key file somewhere safe this time. 😅

Hey Jim!

Since the credentials file contains API keys and other secrets, only the encrypted file gets stored in git. The matching config/credentials.key contains the key to decrypt that file. The key should not be stored in the repo, otherwise it wouldn't be secure and you might as well store the keys in plain text.

So you'll have to grab the config/credentials.key file from your other computer and add it to your laptop.

Keep that key safe like a password. It's the only way to decrypt the credentials.

For background jobs on Ubuntu, you would normally use SystemD.

With sidekiq, you would:

  1. Add the Sidekiq systemd script to /etc/systemd/system/sidekiq.service
  2. sudo systemctl daemon-reload
  3. sudo systemctl enable sidekiq
  4. sudo systemctl start sidekiq

daemon-reload refreshes systemd so it sees the new service.
enable allows it to start when the server boots.
start starts sidekiq

You then want to run sudo systemctl restart sidekiq on deploy so it can pickup the latest Rails code for the jobs.

Posted in PAGY with Rails API Only

Hey Tim,

Normally, you want to pass the next page number into the URL like you mentioned. That's how pagination links work when you display render them. Then the server knows which group of 20 records to grab next.

Rails always sanitizes rendering HTML by default, so it should be fine. Rendering ActionText content is also sanitized and you can use the sanitize helper anytime you want to be sure it gets sanitized.

You just do not want to ever use html_safe or raw which will introduce XSS vulnerabilities because it will not escape content if you use them.

Looks like it's using example.com for the domain so you're probably missing one of the configs to set the default host.

Lots of chat about it in this thread. https://github.com/rails/rails/issues/32500#issuecomment-441664690

And one of the recommended options to try is:

#config/environments/production.rb
config.active_storage.service = :local
config.action_mailer.default_url_options = { host: 'https://domain.com' }
config.default_url_options = { host: "https://domain.com" }

You should try just paginating on the ActiveRecord association instead of the array.

def dashboard
    @gigs = current_user.gigs.page(params[:page]).per(4)
  end

Then in the view

<%= @gigs.each do |gig| %>
<% end %>

<%= paginate @gigs %>

Posted in Recording Building a Rails Based Accounting System

Love the idea! I've thought about doing something like this myself in the past, I just don't have the time. I love watching people stream this stuff on Twitch, so I'm sure other people will enjoy watching it too. 👍

Posted in How long will Rails 5 be supported?

Here's details on the support / maintenance policies for Rails. https://guides.rubyonrails.org/maintenance_policy.html

Only the latest release series will receive bug fixes. When enough bugs are fixed and its deemed worthy to release a new gem, this is the branch it happens from.

The current release series and the next most recent one will receive patches and new versions in case of a security issue.

For severe security issues all releases in the current major series, and also the last release in the previous major series will receive patches and new versions. The classification of the security issue is judged by the core team.

So that means Rails 5.2 will continue receiving security updates until Rails 6.1 is out. Rails 5.1 and earlier are no longer supported.

Hey Alex,

Have you set RAILS_ENV=staging on the server so it knows to run the staging env in production?

Awesome! I like when solutions are that easy. 🤘

Have you double checked to make sure you're indexing the account_id in ElasticSearch?

Posted in Model/concerns question

If you're calling title directly, then you're not calling your capitalize_title method. You would want to call the name method.

Ask and you shall receive! Here's the Uppy episode: https://gorails.com/episodes/uppy-with-active-storage

Posted in Model/concerns question

And your view is calling <%= @subject.name %>?

Posted in Setting background image from User uploaded asset

Hmm, I wonder why then the string was "" then. I assumed that's what it would do when there was no attachment.

Try just printing out the image_url on the page directly. Once you figure out what's missing there, then you can add it to the style attribute.

You can always throw a byebug onto the page so you can fiddle with it while it's rendering.

I think you just want something like:

def index
    query = params[User.where(account_id: Current.account)]  || "*" 

    args = {}
        args[:account_id] = Current.account.id
    args[:first_name] = params[:first_name] if params[:first_name].present?
    args[:languages] = params[:languages] if params[:languages].present?
    @users = User.search query, where: args,
                                aggs: {
                                  first_name: {},
                                  languages: {}
                               }
end

Posted in Setting background image from User uploaded asset

Well, it looks like you don't have an image attached. That will obviously only work if there is an image attached. 🧐