Kiran Patil

Joined 1/9/2018
Kiran Patil said 11 months ago:

Hi,

Can I move all js sprinkle code and jquery plugins  to stimulusjs so that I can organize better and execute page specific js only?

Thanks.

kobaltz PRO said 11 months ago:

You can to some degree. Remember that you will have to have the DOM elements already existing on the page so if any of the referred JS is adding elements, there may be some disconnect with Stimulus. However, a lot of it probably can be moved over. For example, if you have a date picker which has a lot of different attributes and customization, that would probably be a good candidate. A nested forms "Add Item" & "Remove Item" links may not be a good fit since you're adding elements to the DOM.

Kiran Patil said 11 months ago:

Hi,

Please add gitlab CI/CD screencast.

Thanks.

kobaltz PRO said 11 months ago:

Definitely. I use Gitlab CI/CD for my personal projects. 

Kiran Patil said 11 months ago:

Hi,


Does page-specific-js-in-ruby  still make sense, since we have now Stimulus js ?


Thanks.

kobaltz PRO said 11 months ago:

I believe that it does. Not everything needs to be a Stimulus component. Sometimes it just makes sense to have some JS sprinkles where needed. I have personally never been a huge fan of page specific javascript as it seems like there is some disconnect in the architectural planning of the application. I typically tend to write JS functions so that they can be called on later in Server Rendered Javascript responses, when launching a bootstrap modal or wherever else appropriate.

Kiran Patil said 11 months ago:

Hi,


I want to create a subscriber id which should be unique, can we use UUID as subscriber id ?


In general how people are creating unique subscriber id during registration ?


Do we have any ruby gem to get unique id by providing name, date and other parameter as input to the function to get new unique is ?


I also would like to know the pattern to generate ticket id as well, which is used in incident management where each reported incident is a ticket to be resolved.


Thanks.

kobaltz PRO said 11 months ago:

You could use a UUID for this, but I think that it would probably be a bit overkill.

I would personally just do something like this with SecureRandom.hex (which is part of the ruby core)

        before_create :populate_subscriber_id
        private
        def populate_subscriber_id
          begin
            self.subscriber_id = SecureRandom.hex
          end while self.class.exists?(subscriber_id: subscriber_id)
        end

Kiran Patil said 11 months ago:

Hi,


Please add nginx with puma configuration for production.


Thanks.

kobaltz PRO said 11 months ago:

This is the config that I use for nginx/puma. The puma.rb is within the rails application's config folder.

nginx.conf

upstream backend {
  server unix:///var/run/puma/my_app.sock;
}
server {
  listen 80;
  server_name _ localhost;
  access_log /var/log/nginx/access.log main;
  error_log /var/log/nginx/error.log;
  large_client_header_buffers 8 32k;
  root /var/app/current/public;
  location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    proxy_buffers 8 32k;
    proxy_buffer_size 64k;
    proxy_pass http://backend;
    proxy_redirect off;
    # enables WS support
    location /cable {
      proxy_pass http://backend;
      proxy_http_version 1.1;
      proxy_set_header Upgrade "websocket";
      proxy_set_header Connection "Upgrade";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
  }
  
  location /assets {
    alias /var/app/current/public/assets;
    gzip_static on;
    gzip on;
    expires max;
    add_header Cache-Control public;
  }
  location /public {
    alias /var/app/current/public;
    gzip_static on;
    gzip on;
    expires max;
    add_header Cache-Control public;
  }
}

config/puma.rb

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads 2, threads_count
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
workers ENV.fetch("WEB_CONCURRENCY") { 2 }
preload_app!
before_fork do
  ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
end
on_worker_boot do
  ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end
plugin :tmp_restart


Kiran Patil said 11 months ago:

Thanks, one more thing is don't we need daemonize to run puma in background and environment is pointing to "development" in pumb.rb but it should be "production".

Kiran Patil said 11 months ago:

Thanks, one more thing is don't we need daemonize to run puma in background and environment is pointing to "development" in pumb.rb but it should be "production".

Kiran Patil said 10 months ago:

Hi,

Have you used capistrano for app deployment ?

Please throw some light on it.

Thanks.

Kiran Patil said 10 months ago:

What would be configuration/tuning for postgresql on production ?

kobaltz PRO said 10 months ago:

I don't do too much with PostgreSQL, but is there specific cases that you're looking for?

Kiran Patil said 10 months ago:

No, I am looking for generic configuration tuning for on-premise server.

Kiran Patil said 10 months ago:

No, I am looking for generic configuration tuning for on-premise server.