Srinivasa Varma

Joined

990 Experience
7 Lessons Completed
0 Questions Solved

Activity

Posted in Rails Engines for Decoupled Architecture

@Alexander Miasoiedov

Have you found any solution to it? please share if you have any. I am also looking for the same architecture. 

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

How to start ab_test on Javascript/StimulusJs click events?

In a product page I have multiple lead capturing forms, the form get opend in a popup by clicking in the link/button. Now I want to test which link/button click is giving more leads.

Thanks!

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

Any luck? I am also getting the same.

@jacob Montgeomery

I've checked all the required folders for file storage and all are there. The form submitting smoothly when i added single file, but when i add multiple file it showing only redirection and nothing happening after that.

Posted in How to perform bulk update in rails?

Hi there,

Here is the problem in more detail. I tried to perform bulk update on rails model, but ended up with normal save method. I have some number of records and i wanted to update their values with respect to performed calculations. But i could not find a solution to do that. Any ideas appereciated.

Below is my rails task code:

  wsp = Wsp.includes(:collections)
    wsp.each do |ws|
         ws.set_margin_attributes
         ws.save(validate: false)
    end

and Wsp model contains set_margin_attributes method like below

    def set_margin_attributes(ws_calculations)
            self.attributes = {
                total_amount: ws_calculations[:total_amount],
                margin: ws_calculations[:margin],
                margin_percent: ws_calculations[:margin_percent],
                inr_margin: ws_calculations[:inr_margin]
            }
        end

Can some one suggest is there any otherway to do this.

Thanks in advance

Hi Jacob,

I've already checked in nginx conf and it has client_max_body_size 50M; For uploading images i'm using paperclip for one image upload and manually moving another image. Both are different kinds of upload.

Hi Jacob,

The files aren't large in size. I'm trying to upload two image files from a single form. So, i think size does not matter then.

Hi there,

I'm trying to upload multiple file inputs from single form. The form is working fine in development, but in production the form showing that redirecting for long time and returns nothing. Can some one help me to resolve this issue.

Thanks in advance.

Hi Guys.

Recently i ran into a problem which does not allowing me to render a partial as a JSON response for .json requests. Below you can get in more detail.

I have a partial resides in below path:
views/sales/manage_data/_spoc_li.html.erb

I have tried two approaches to render that partial as a response.

  1. Using normal controller action as html response ( i have accessed localhost:3000/sales/spocs)
    Following is my controller action code:

    def index
    @products = Product.all
    @spocs = Spoc.all
    render json: {
      html_data: render_to_string(partial: 'sales/manage_data/spoc_li', locals: {spoc: @spocs[0]})
    }
    end
    

    It did not raised any error and i can see json response in browser.

  2. Using .json request ( i have accessed localhost:3000/sales/spocs.json)

def index
    @products = Product.all
    @spocs = Spoc.all
    respond_to do |format|
      format.html
      format.json { render json:{
          html_data: render_to_string(partial: 'sales/manage_data/spoc_li', locals: {spoc: @spocs[0]})
        }
      }
    end
  end

This time it raised an error saying that

Missing partial sales/manage_data/_spoc_li with {:locale=>[:en], :formats=>[:json], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :coffee, :jbuilder]}. Searched in: * "/home/enigma/workspace/collections/app/views" * "/home/enigma/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ckeditor-4.2.2/app/views" * "/home/enigma/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.2.0/app/views"

Some please tell how formats are working and how can i get rid of this?

Thanks

Hi

I changed my server also for this reason. Even then the problem still exist.
I just deployed app using capistrano and during deploy process my cpu reaches to 100%.

I used 'top -ic' command then i get following result

top - 10:48:14 up 23:51, 2 users, load average: 7.47, 7.58, 7.13
Tasks: 167 total, 1 running, 166 sleeping, 0 stopped, 0 zombie
%Cpu(s): 35.9 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 64.1 st
KiB Mem : 4045040 total, 169484 free, 2827428 used, 1048128 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 1108364 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

3637 deploy 20 0 499564 165644 10436 S 35.8 4.1 305:37.51 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
6669 deploy 20 0 494112 178280 7352 S 34.8 4.4 291:43.09 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
3650 deploy 20 0 494204 177568 7392 S 33.1 4.4 298:59.78 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
8735 deploy 20 0 563904 180032 10540 S 31.8 4.5 97:30.69 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
8743 deploy 20 0 494216 174424 7388 S 30.5 4.3 94:15.07 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
10114 deploy 20 0 428576 171136 7364 S 29.1 4.2 91:26.35 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)

Hi Jacob Montgomery,

I ran top command and it showing following

top - 10:48:14 up 23:51, 2 users, load average: 7.47, 7.58, 7.13
Tasks: 167 total, 1 running, 166 sleeping, 0 stopped, 0 zombie
%Cpu(s): 35.9 us, 0.0 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 64.1 st
KiB Mem : 4045040 total, 169484 free, 2827428 used, 1048128 buff/cache
KiB Swap: 0 total, 0 free, 0 used. 1108364 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND

3637 deploy 20 0 499564 165644 10436 S 35.8 4.1 305:37.51 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
6669 deploy 20 0 494112 178280 7352 S 34.8 4.4 291:43.09 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
3650 deploy 20 0 494204 177568 7392 S 33.1 4.4 298:59.78 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
8735 deploy 20 0 563904 180032 10540 S 31.8 4.5 97:30.69 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
8743 deploy 20 0 494216 174424 7388 S 30.5 4.3 94:15.07 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)
10114 deploy 20 0 428576 171136 7364 S 29.1 4.2 91:26.35 Passenger RubyApp: /home/deploy/testprep_rails/current/public (production)

My Nginx error log says that some passenger ruby processes are running long time and taking too much CPU usage. Still problem exist please have look at my app nginx error log.

[ 2016-10-24 23:02:18.7328 21683/7fec0566a700 age/Cor/CoreMain.cpp:532 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2016-10-24 23:02:18.7328 21683/7fec0c265780 age/Cor/CoreMain.cpp:901 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2016-10-24 23:02:18.7328 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 21780, application /home/deploy/testprep_rails/current/public (production)
[ 2016-10-24 23:02:18.7329 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 21788, application /home/deploy/testprep_rails/current/public (production)
[ 2016-10-24 23:02:18.7329 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 26979, application /home/deploy/testprep_rails/current/public (production)
[ 2016-10-24 23:02:18.7329 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 29348, application /home/deploy/testprep_rails/current/public (production)
[ 2016-10-24 23:02:18.7329 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 624, application /home/deploy/testprep_rails/current/public (production)
[ 2016-10-24 23:02:18.7329 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 3289, application /home/deploy/testprep_rails/current/public (production)
[ 2016-10-24 23:02:18.7329 21683/7fec0c265780 age/Cor/CoreMain.cpp:819 ]: Checking whether to disconnect long-running connections for process 22519, application /home/deploy/testprep_rails_staging/current/public (staging)
[ 2016-10-24 23:02:18.7330 21683/7febe7fff700 Ser/Server.h:817 ]: [ApiServer] Freed 0 spare client objects
[ 2016-10-24 23:02:18.7330 21683/7febe7fff700 Ser/Server.h:464 ]: [ApiServer] Shutdown finished

[ 2016-10-24 23:02:18.7331 21688/7f5c3c815700 age/Ust/UstRouterMain.cpp:422 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2016-10-24 23:02:18.7331 21688/7f5c4344f780 age/Ust/UstRouterMain.cpp:492 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2016-10-24 23:02:18.7348 21688/7f5c2ffff700 Ser/Server.h:817 ]: [UstRouterApiServer] Freed 0 spare client objects
[ 2016-10-24 23:02:18.7355 21688/7f5c2ffff700 Ser/Server.h:464 ]: [UstRouterApiServer] Shutdown finished
[ 2016-10-24 23:02:18.7357 21688/7f5c3c815700 Ser/Server.h:464 ]: [UstRouter] Shutdown finished
[ 2016-10-24 23:02:18.7359 21688/7f5c4344f780 age/Ust/UstRouterMain.cpp:523 ]: Passenger UstRouter shutdown finished
2016/10/24 23:02:19 [info] 3530#3530: Using 32768KiB of shared memory for push module in /etc/nginx/nginx.conf:71
[ 2016-10-24 23:02:19.8095 3538/7fe734526780 age/Wat/WatchdogMain.cpp:1291 ]: Starting Passenger watchdog...
[ 2016-10-24 23:02:19.8169 3541/7fc6d76d2780 age/Cor/CoreMain.cpp:982 ]: Starting Passenger core...
[ 2016-10-24 23:02:19.8170 3541/7fc6d76d2780 age/Cor/CoreMain.cpp:235 ]: Passenger core running in multi-application mode.
[ 2016-10-24 23:02:19.8185 3541/7fc6d76d2780 age/Cor/CoreMain.cpp:732 ]: Passenger core online, PID 3541
[ 2016-10-24 23:02:19.8266 3546/7fd1a4535780 age/Ust/UstRouterMain.cpp:529 ]: Starting Passenger UstRouter...
[ 2016-10-24 23:02:19.8290 3546/7fd1a4535780 age/Ust/UstRouterMain.cpp:342 ]: Passenger UstRouter online, PID 3546

Hi

My rails app production server CPU usage sometimes reaches to 100% and making app to be unresponsive. We are using Ubuntu 16.04.1 LTS server and configured Rails app along with Nginx and passenger as suggested in gorails deploy ruby on rails tutorial. I don't know why this is happening and it leads to website down for so many times. If anyone has any solution to fix this please tell me.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.