Dan Tappin

Joined

8,820 Experience
5 Lessons Completed
9 Questions Solved

Activity

👍

I will say that ElasticSearch / SearchKick is amazing. Glad to have finally purged all my old Ransack code.

Hmmm... now just read it doesnt support server side processing yet :(

Posted in Looking for a secure place to store scanned tax forms

I am pretty sure that AWS S3 has an option to store files with encryption.

Posted in EleasticSearch and Indexing Empty Models

That was the trick - I should have spent more time searching the issues and I would have found that. If any one else hits this issue also note the requirement to add the second level of { } to the order query. That is not obvious. Just spent 10 minutes baning my head against the wall. 🤦‍♂️

Posted in EleasticSearch and Indexing Empty Models

I have added Elastic Search to my Rails app via the Searchkick gem. I have hit a snag - when I have a model with no records I get these errors:

Searchkick::InvalidQueryError: [400] {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [name] in order to sort on"...

My controller by default is trying to sort the results but there are no results in the index so this fails. A plain old .search("*") returns no results - as expected. It seems that the reindex runs but the index doesn't build the mappings because there is no data.

I know I could add some logic before my search (like a Model.count) but this seems non-ideal. Am I missing a basic ElasticSearch feature here or any other ways to avoid this?

Posted in JSON Web Token Authentication From Scratch Discussion

i am looking at adding an API to my app i want to keep it simple like many other apps uses and a single API key for the account to access my account data.

All these tutorials seemed geared towards user based authentication.

is one way better or worse than the other?

Posted in Bizarre cache issue

How do I force the browser to always refresh parts or all of the content?

I have a bizzare issue where the browser is caching parts of the site. For example I have a 'History' for a model row in the DB. I add a comment, update etc. If I visit the History page then navigate to another action that adds a history then return to the history page it is the old version. If I refresh I get the new content. I am now finding these issues everywhere in my site.

I can confirm that there are no hits to the server so it's not a Rails caching issue - seems to be browser based.

Any ideas?

I have a Rail app where the user can switch tenants (activerecord_acts_as_tenant). The issue is that in production the browser is caching the old client HTML etc.

I came across this:

https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers

headers["Cache-Control"] = "no-cache, no-store, must-revalidate" # HTTP 1.1.
headers["Pragma"] = "no-cache" # HTTP 1.0.
headers["Expires"] = "0" # Proxies.

I have a controller that sets a session variable and then redirects to root. I want to 'reset' the cache etc. at this point but I can't seem to figure out how to implement this.

It's very bizzare. The browser keeps the old HTML even over manual refreshes. Tried again this morning to have the site even load the page after Devise had timed out. The datatables failed as they were calling JSON from the live site but authentication failed so they throw errors.

Posted in Multitenancy with the Apartment gem Discussion

I guess I should have been clearer - I have a SSO type system with an 'enrollment' between the tenant and the user (the same user can access multiple tenants with a single login). The enrollment holds the tenant information.

My thought is to just store the tenant name in a session variable. Then I can switch the enrollment and then the app controller can switch the tenant based on the stored session.

Posted in Multitenancy with the Apartment gem Discussion

Question - how are you setting the tenant? Just saving a simple session variable with the tenant name?

Posted in Multitenancy with the Apartment gem Discussion

I am seriously considering switching now. When the developers of Apartmment say don't use Apartment that is a sign lol

Posted in Polymorphic Search

I have a basic model structure like this:

class History < ActiveRecord::Base
  belongs_to :historical, polymorphic: true, touch: true
end

with several related models:

has_many :history, :as => :historical, :dependent => :destroy

It seem to me that there is no easy way to search the History model AND the related models. For example each related model has a name and notes field. Can I do some sort of crazy multiple join and use conditions on the join?

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Getting close:

    # routes.rb

  authenticated :user do
    get '/help', to: redirect('https://help.insertyour.domain'), as: :help
  end

  unauthenticated do
    get '/help', to: 'home#dashboard'
  end

This solves the redirect but created another issue. The help site sends you to the main site (https://app.insertyour.domain/help) signup page. You authenticate and then devise sends you back to the help site and it allows access. The problem is that if you go back to the main app you have to authenticate again. It's not idea but works for now. Not sure why a new attempt to access the main site requires authentiction again.

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

That was perfect - I still need to sync the users but for now it's gold. Here is what I did:

  • used the same secret access key on both apps
  • added :domain => ".insertyour.domain)" so the session_store.rb directive
  • on my helpy deploy I added an application before_action: redirect_to 'https://app.insertyour.domain/help/' if session[:enrollment_id].nil?
  • on my main app routes I have: get '/help', to: redirect('https://help.insertyour.domain'), as: :help

The idea here was that if you hit the help site not authenticated you get redirected to the main app help path, Devise would authenticate then send you back to the help site. The issue is that I now get a ERR_TOO_MANY_REDIRECTS error. Any ideas on how to make this work?

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Back to the cookies idea. I synced the key base. I want to start with setting an expiring cookie on the main app then confirming in Helpy that it's set. If not redirect to the main app. I will add the Devise synce later.

I tried setting a cookie on the main app then displaying the contents in Helpy but no dice. Any pointers?

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Yup - ran the seed file and all was good.

FYI - Hatchbox makes these deploys painless. If the seed had not failed I would have had Helpy deployed from scratch in 10 minutes. 👍

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

I downloaded the repo locally and fired it up. The onboarding page asks you info and sets up the first user etc. (like WordPress does etc.). I the pushed this to my GH account and deployed in my Hatchbox account and deployed. It looks like the seedfile didn't run. Going to try and run that manually...

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Chris - any tips to deply Helpy? I am hitting this issue:

https://github.com/helpyio/helpy/issues/1517

onboarding_controller.rb in index at line 8

onboarding_controller.rb:8:in `index'

  def index
    @user = User.first
    @user.name = ""
    @user.email = ""
    @user.password = ""
  end

Posted in Sub-site Authentication? (FAQ / KB / Helpdesk etc.)

Thanks - I will give that a try and post my results 👍