Masud Hossain

Joined

3,660 Experience
3 Lessons Completed
3 Questions Solved

Activity

Posted in How to use Uppy with ActiveStorage Discussion

+1 for shrine

Posted in A/B Split Testing with the Split gem Discussion

Can't believe I'm finding this gem just now.

Traditional file upload (click upload and than click submit) works fine, but when i try to use the jquery fileupload with AJAX to make a post request to the server, it'll return a CORS error. I saw that Digitalocean had cors settings, but only for GET, PUT, and DELETE. I'm assuming not having POST is the issue here.

Any idea how I can get POST to work? (I'm using hatch to push site to production if that helps).

Posted in Hatchbox.io redirecting subdomains to https

I tried out hatchbox.io's SSL encrypt for a new domain. And it's rerouting my http://something.example.com to the https://something.example.com. Any way I can keep it from redirecting it to the https for subdomains?

Additional info:

  1. For DNS, I did a CNAME where * is an alias of example.com
  2. Using hatchbox.io for pushing code and SSL.
  3. Using digital ocean for my hosting.
  4. Using google domains for my domain (DNS setting is inside digitaloceans though).

Posted in Incorrect setup for Model associations

@Tabish Iqbal,

do you mind showing me how the models would be set up? I don't seem to understand how the self joins would work in this case.

Posted in Incorrect setup for Model associations

I feel these associations are incorrectly set up. It's a bit similar to Trello, except I'm adding in a 'client' model too. The main part that's confusing to me is the fact user.rb, it's just bugging me.

https://docs.google.com/spreadsheets/d/17HLjRnIrs-lf_nNwJKj3ijkC2HnfEmti2wVFdx6kG9Y/edit?usp=sharing

What it's suppose to do:

  1. A user can create a business and belong to it as an employee.
  2. A business can have multiple employees (and a user belongs to that specific employee).
  3. A business can have multiple clients (and a user belongs to that specific client).

Is there a more efficient way to set this up?

Found out the problem was nginx. There's a size limitation (http://prntscr.com/fz5713) on hatch under Nginx settings, so i changeg it to 900mb and now it's uploading fine.

I built my file upload using Chris's guide (https://gorails.com/series/direct-uploads-to-amazon-s3), and i'm trying to figure out a way to increase limit the upload size of each file. Right now it seems like it's set to 5MB max.

Does anyone know how to do this?

Posted in 3rd party integrations using Oauth/omniauth

So the 'user = User.from_omniauth(env["omniauth.auth"])' will still go in the sessions_controller under create method?

Or does it make more sense to put it under the update method in sessions controller to do the attaching part to the current user logged in

Posted in 3rd party integrations using Oauth/omniauth

When creating a facebook login, you put user = User.from_omniauth(env["omniauth.auth"]) inside sessions_controller.rb , so when a user goes to /auth/facebook it will prompt them to login via facebook. And now the user will automatically have all his data pulled from facebook and it'll create a session based on it.

But what if I want to create an integration (let's say Salesforce for example) with an already logged in user and than pull data from Salesforce?
Where would I put the user = User.from_omniauth(env["omniauth.auth"]) at that point and how can I make sure the 'integration' stays put even after they log off and than log back in ?

I've had some tough time finding guides on this, because most of the guides are for logging in a user and creating a session, not integrating with 3rd parties.

I'm trying to create a sign_up form where the user will choose his email + password AND and Article at the same time as creating a user account.

So assentially, one form will create a new User and it will also create a new Article.

This is my new user form

<%= form_for(@user, url: registrations_path) do |f| %>

        <%= f.email_field :email %>

        <%= f.password_field :password %>

        <%= f.password_field :password_confirmation %>

        <%= submit_tag "Sign up", :class => "signupsubmit" %>

<%  end %>

And my new article form

<%= form_for(@article) do |f| %>

    <%= f.text_field :url  %>

    <%= f.submit "Submit"  %>

<% end %>

Essentially i want to combine these two forms into ONE.

Posted in Resource on how to do filters with checkboxes

I'm trying to create a way to filter my User results based on these filters. I'm looking for a guide with example on how to do this.

http://image.prntscr.com/image/07e7113ac239436fa129fa874b5acfa1.png

Posted in [HATCH] Error deploying app

Thanks, Chris!

*Solution: My migration files were out of order. I was making a reference to :users when my user migration files were 3rd place. I changed the dates so users are created first, and done. *

Posted in [HATCH] Error deploying app

I'm getting this error when trying to deploy my project with hatch. I made sure I have the RSA file.

Deployment Error

Fetching origin
Warning: Identity file /home/deploy/.ssh/thinkrtc_rsa not accessible: No such file or directory.
Overwriting config/database.yml...
Installing gems...
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Using rake 12.0.0
Using concurrent-ruby 1.0.5
Using i18n 0.8.1
Using minitest 5.10.1
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using rack 2.0.1
Using nio4r 2.0.0
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using jsonapi-renderer 0.1.2
Using arel 7.1.4
Using public_suffix 2.0.5
Using bcrypt 3.1.11
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.4
Using cookiejar 0.3.3
Using daemons 1.2.4
Using eventmachine 1.2.3
Using http_parser.rb 0.6.0
Using multi_json 1.12.1
Using json 1.8.6
Using request_store 1.3.2
Using tilt 2.0.6
Using multi_xml 0.6.0
Using nested_form 0.3.2
Using pg 0.19.0
Using puma 3.7.1
Using rack-cors 0.4.1
Using bundler 1.14.6
Using rails_serve_static_assets 0.0.5
Using rails_stdout_logging 0.0.5
Using remotipart 1.3.1
Using sass 3.4.23
Using redis 3.3.3
Using turbolinks-source 5.0.0
Using faker 1.7.3
Using tzinfo 1.2.2
Using nokogiri 1.7.0.1
Using rack-test 0.6.3
Using sprockets 3.7.1
Using websocket-driver 0.6.5
Using mime-types 3.1
Using addressable 2.5.0
Using coffee-script 2.4.1
Using uglifier 3.1.4
Using em-socksify 0.3.1
Using thin 1.7.0
Using haml 4.0.7
Using httparty 0.13.7
Using rails_12factor 0.0.3
Using turbolinks 5.0.1
Using activesupport 5.0.2
Using loofah 2.0.3
Using rack-pjax 1.0.0
Using faye-websocket 0.10.7
Using mail 2.6.4
Using em-http-request 1.1.5
Using pushwoosh 1.0.1
Using rails-dom-testing 2.0.2
Using globalid 0.3.7
Using activemodel 5.0.2
Using case_transform 0.2
Using jbuilder 2.6.3
Using opentok 2.3.4
Using skylight 1.0.1
Using rails-html-sanitizer 1.0.3
Using faye 1.2.4
Using activejob 5.0.2
Using activerecord 5.0.2
Using actionview 5.0.2
Using private_pub 1.0.3
Using acts_as_list 0.9.2
Using friendly_id 5.1.0
Using actionpack 5.0.2
Using actioncable 5.0.2
Using actionmailer 5.0.2
Using active_model_serializers 0.10.5
Using railties 5.0.2
Using gon 6.1.0
Using kaminari 0.17.0
Using meta-tags 2.4.0
Using sprockets-rails 3.2.0
Using coffee-rails 4.2.1
Using font-awesome-rails 4.7.0.1
Using jquery-rails 4.2.2
Using jquery-ui-rails 5.0.5
Using rails 5.0.2
Using sass-rails 5.0.6
Using rails_admin 1.1.1
Bundle complete! 37 Gemfile dependencies, 94 gems now installed.
Gems in the groups development and test were not installed.
Bundled gems are installed into /home/deploy/thinkrtc/shared/bundle.
Precompiling assets...
[SKYLIGHT] [1.0.1] Skylight agent enabled
I, [2017-03-22T00:34:54.485242 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/rails_admin/rails_admin-5a3ff98fc95ac99b3f9a2afa536583f8defe82277ad26eedc61ecf40c837fb92.js
I, [2017-03-22T00:34:54.488992 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/rails_admin/rails_admin-5a3ff98fc95ac99b3f9a2afa536583f8defe82277ad26eedc61ecf40c837fb92.js.gz
I, [2017-03-22T00:34:54.586618 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/rails_admin/jquery.colorpicker-3a11f7b1b3e47236ba6d015c2c3cc4a29c600da1136afee9faedefb94412d524.js
I, [2017-03-22T00:34:54.586908 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/rails_admin/jquery.colorpicker-3a11f7b1b3e47236ba6d015c2c3cc4a29c600da1136afee9faedefb94412d524.js.gz
I, [2017-03-22T00:34:55.114850 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/application-af631dd2d8d2d8ddcfa7b4ae66a191a7f5bc5fc08b771a91d5e35f6f32925fab.js
I, [2017-03-22T00:34:55.116075 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/application-af631dd2d8d2d8ddcfa7b4ae66a191a7f5bc5fc08b771a91d5e35f6f32925fab.js.gz
I, [2017-03-22T00:34:55.142056 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/application-7dd308a3f628e9787da0486950bfa7262a0b6dd9a1894b8eb194d3a92c60d8ce.css
I, [2017-03-22T00:34:55.142580 #4084]  INFO -- : Writing /home/deploy/thinkrtc/releases/20170322003438/public/assets/application-7dd308a3f628e9787da0486950bfa7262a0b6dd9a1894b8eb194d3a92c60d8ce.css.gz
Migrating database...
[SKYLIGHT] [1.0.1] Skylight agent enabled
   (0.4ms)  SELECT pg_try_advisory_lock(7446154116381427335);
  ActiveRecord::SchemaMigration Load (1.0ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Migrating to CreatePersonalMessages (20160616153620)
   (8.3ms)  BEGIN
== 20160616153620 CreatePersonalMessages: migrating ===========================
-- create_table(:personal_messages)
   (44.5ms)  CREATE TABLE "personal_messages" ("id" serial primary key, "body" text, "conversation_id" integer, "user_id" integer, "position" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_41ff46a8ff"
FOREIGN KEY ("conversation_id")
  REFERENCES "conversations" ("id")
, CONSTRAINT "fk_rails_1250fcec6d"
FOREIGN KEY ("user_id")
  REFERENCES "users" ("id")
)
   (0.5ms)  ROLLBACK
   (0.6ms)  SELECT pg_advisory_unlock(7446154116381427335)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR:  relation "users" does not exist
: CREATE TABLE "personal_messages" ("id" serial primary key, "body" text, "conversation_id" integer, "user_id" integer, "position" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_41ff46a8ff"
FOREIGN KEY ("conversation_id")
  REFERENCES "conversations" ("id")
, CONSTRAINT "fk_rails_1250fcec6d"
FOREIGN KEY ("user_id")
  REFERENCES "users" ("id")
)
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:278:in `create_table'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:846:in `block in method_missing'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `block in say_with_time'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `say_with_time'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:835:in `method_missing'
/home/deploy/thinkrtc/releases/20170322003438/db/migrate/20160616153620_create_personal_messages.rb:3:in `change'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:789:in `exec_migration'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:773:in `block (2 levels) in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:772:in `block in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:771:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:951:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1214:in `block in execute_migration_in_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `block in ddl_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `ddl_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1213:in `execute_migration_in_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1185:in `block in migrate_without_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `each'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `migrate_without_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `block in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1301:in `with_advisory_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1006:in `up'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:984:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/2.3.3/bin/bundle:22:in `load'
/home/deploy/.rbenv/versions/2.3.3/bin/bundle:22:in `<main>'
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "users" does not exist
: CREATE TABLE "personal_messages" ("id" serial primary key, "body" text, "conversation_id" integer, "user_id" integer, "position" integer, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_41ff46a8ff"
FOREIGN KEY ("conversation_id")
  REFERENCES "conversations" ("id")
, CONSTRAINT "fk_rails_1250fcec6d"
FOREIGN KEY ("user_id")
  REFERENCES "users" ("id")
)
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:278:in `create_table'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:846:in `block in method_missing'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `block in say_with_time'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `say_with_time'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:835:in `method_missing'
/home/deploy/thinkrtc/releases/20170322003438/db/migrate/20160616153620_create_personal_messages.rb:3:in `change'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:789:in `exec_migration'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:773:in `block (2 levels) in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:772:in `block in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:771:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:951:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1214:in `block in execute_migration_in_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `block in ddl_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `ddl_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1213:in `execute_migration_in_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1185:in `block in migrate_without_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `each'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `migrate_without_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `block in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1301:in `with_advisory_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1006:in `up'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:984:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/2.3.3/bin/bundle:22:in `load'
/home/deploy/.rbenv/versions/2.3.3/bin/bundle:22:in `<main>'
PG::UndefinedTable: ERROR:  relation "users" does not exist
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:278:in `create_table'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:846:in `block in method_missing'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `block in say_with_time'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:815:in `say_with_time'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:835:in `method_missing'
/home/deploy/thinkrtc/releases/20170322003438/db/migrate/20160616153620_create_personal_messages.rb:3:in `change'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:789:in `exec_migration'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:773:in `block (2 levels) in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:772:in `block in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `with_connection'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:771:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:951:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1214:in `block in execute_migration_in_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `block in ddl_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `block in transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/transaction.rb:189:in `within_new_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:232:in `transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/transactions.rb:211:in `transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1282:in `ddl_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1213:in `execute_migration_in_transaction'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1185:in `block in migrate_without_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `each'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1184:in `migrate_without_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `block in migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1301:in `with_advisory_lock'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1132:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:1006:in `up'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/migration.rb:984:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/tasks/database_tasks.rb:161:in `migrate'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/activerecord-5.0.2/lib/active_record/railties/databases.rake:58:in `block (2 levels) in <top (required)>'
/home/deploy/thinkrtc/shared/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/deploy/.rbenv/versions/2.3.3/bin/bundle:22:in `load'
/home/deploy/.rbenv/versions/2.3.3/bin/bundle:22:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Or do I need to just migrate to Digital ocean in case it's a DNS problem?

I'm doing a CNAME for example.com => example.herokuapp.com for my DNS settings.

So I built a website and pushed it to heroku production example.herokuapp.com and bought a domain to reroute example.com to show whatever is on example.herokuapp.com.
This all works great, except when it comes to actioncable.

This is my cable.js code:

//= require action_cable
//= require_self
//= require_tree ./channels

(function() {
  this.App || (this.App = {});

  var queryString = window.location.search.slice(1);
  var params = {};

  var arr = queryString.split("&");
  for(var key in arr){
    var arr2 = arr[key].split("=");
    params[arr2[0]] = arr2[1];
  }

  App.cable = ActionCable.createConsumer("wss://example.herokuapp.com/cable?token=" + params["token"]);
}).call(this);

I've tired changing the wss://example.herokuapp.com to wss://example.com, but that still doesn't fix the issue. The website is requiring it to be wss://example.herokuapp.com for some reason.

Any idea how to make this work?

Posted in Cookies vs token for authentication

@chris Thanks for the resources and explanation! I'm using token based authentication on my iOS app which is of course connected to my rails backend (my friend developed the iOS , not me).

I should note that i'm basically trying to create intercom.io, so my 'api' would be installed in other websites and it needs to work nicely with CORS. It's just a<script> src="example.com/widget.js"</script>type.

Unfortunatetly, Safari doesn't allow you to store 3rd party cookies from an iframe unless the user has been to the iframe's origin domain. So, I THINK token based authentiation fixes this problem and maybe this is how intercom.io is overcoming this issue with tokens. And the authentication is very important, otherwise you can't keep track of which visitor you're having a conversation with on your website.

Also, I can return a cookie by doing<%= cookies[:username] %>, but how would one do this for tokens?

Possibly <%=request.headers["username"] %>???

EDIT 1: Regarding Safari, I think postMessage might be a possible solution to passing in a cookie to the parent domain and than passing that cookie to the iframe so that it can search for the user or whatever they wish? https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
Thoughts?

Posted in Cookies vs token for authentication

Well, that brings up another question.

Let's say you set it up a way to store a cookie where cookiename = "johndoe".

With cookies in rails, you can easily grab whatever is inside cookiename by doing cookies[:cookiename]and get johndoe returned.

What about with tokens???

Posted in Cookies vs token for authentication

You can keep a users session logged in by putting their cookies into the browser .
But what about if youre using token based authentication instead and the users browser doesn't allow cookies ? How do you store a session at that point?

Posted in Is Actioncable + Redis compatible with APN's?

I built my chat app using rails actioncable and than was able to make an ios app that pulls the conversation and messages. Everything works fine.

My question is, is it possible to set up apple push notifications when im using actioncables? I do want to use pushwoosh.com to handle a lot of the grunt work, but I'm having trouble wrapping my head around how an Apple push notification will work with a socket based connection like actioncable.