naveen kumar

Joined

3,470 Experience
9 Lessons Completed
3 Questions Solved

Activity

Posted in How to manage upstream with ssl?

I am trying to deploy with nginx puma using upstream so
should i use ssl connection with my upstream https://my_app

upstream my_app {
server 127.0.0.1:9292; # or the port you configured in puma configuration file
}

server {
listen 443 ssl ;

    ssl_certificate /etc/ssl/certs/2020.crt;
    ssl_certificate_key /etc/ssl/private/2020.key;
    #ssl_dhparam /etc/ssl/certs/dhparam.pem;


    server_name demoapi.example.com ;

    root /var/www/vhosts/demoapi.example.com/public;


            location / {
                    proxy_pass http://my_app; # match the name of upstream directive which is defined above
                    proxy_set_header Host $host;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }

            location ~* ^/assets/ {
                    # Per RFC2616 - 1 year maximum expiry
                    expires 1y;
                    add_header Cache-Control public;

                    # Some browsers still send conditional-GET requests if there's a
                    # Last-Modified header or an ETag header even if they haven't
                     # reached the expiry date sent in the Expires header.
                    add_header Last-Modified "";
                    add_header ETag "";
                    break;
            }
           location /cable {
                    proxy_pass http://my_app;
                    proxy_http_version 1.1;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection "upgrade";
           }
    }

Posted in How to i implement adobe e sign in rails 5?

No gem available for adobe e sign

Posted in How to i implement adobe e sign in rails 5?

Echochamber is not up to date and also not working , i have found the working python app, should i use python to process the document , help me guys.

you can use association between article and user and use nested attributes in it.

undefined local variable or method `user_signed_in' in application controller

but working fine in application.html.erb

if user_signed_in

layout 'admin_lte_2'
else
layout 'some_other_layout'
end
why is that?

how to add a method in the private section of controller using your method?

I want to store the user activity by using after_action in the all the controller for a specific action of those controller

Posted in Handling multiple Account types

I also have the same requirements the best solution i have found is using "devise + rolify+ cancancan" and then customise devise controller to add roles and after_sign_in_path on the basis of roles.

i found the problem here , some css class issue

Posted in why destroy action is called two times.

when i put this link_to in the modal it automatically started working correctly . You are right modal trying to update after the destroy , the code is working fine now.

my html

<!DOCTYPE html>
<html lang="en">
  <head>
    <%= csrf_meta_tags %>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">



    <%= stylesheet_link_tag "bootstrap.min", media: :all %>
    <%= stylesheet_link_tag "dataTables.bootstrap.min", media: :all %>
    <%= stylesheet_link_tag "responsive.bootstrap", media: :all %>
    <%= stylesheet_link_tag "font-awesome.min", media: :all %>
    <%= stylesheet_link_tag "custom.min", media: :all %>
    <%= stylesheet_link_tag "main", media: :all %>


  </head>
    <body>
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
        <div class="menu_section">
          <h3>Facility</h3>
          <ul class="nav side-menu">
            <li class="active"><a href="facility-dashboard.html"><i class="fa fa-home"></i> Dashboard </a></li>
            <li><a href="my-facilities.html"><i class="fa fa-cubes"></i> My Facilities </a></li>
    <li><a href="statement.html"><i class="fa fa-paste"></i> Statements</a></li>
    <li><a href="billing-information.html"><i class="fa fa-list-alt"></i> Billing information</a></li>
    **<li><a><i class="fa fa-gears"></i> Account Setting <span class="fa fa-chevron-down"></span></a>** 
    <ul class="nav child_menu"> 
      <li><a href="javascript:void(0);">One</a></li>
      <li><a href="javascript:void(0);">Two</a></li>
      <li><a href="javascript:void(0);">Three</a></li>
    </ul>
    </li>
  </ul>
        </div>
      </div>

<%= javascript_include_tag "application" %>
<%= javascript_include_tag "bootstrap.min" %>

<%= javascript_include_tag "dataTables.bootstrap.min" %>
<%= javascript_include_tag "dataTables.responsive" %>
<%= javascript_include_tag "custom.min" %>
  </body>
</html>

my application.js

//= require jquery2
//= require jquery_ujs

Posted in why destroy action is called two times.

<%= link_to "YES", admins_manage_client_path(owner),remote: true, method: :delete,id: owner.id, class: "btn btn-danger", :'data-dismiss' =>"modal" %>

now its working  without any double calling destroy

Posted in why destroy action is called two times.

this is my application.js
//
//= require jquery2
//= require jquery_ujs
// require turbolinks
// require_tree .

already disabled turbolinks

Posted in why destroy action is called two times.

my destroy action

def destroy
@owner = User.find(params[:id])
@owner.destroy

respond_to do |format|
format.html { redirect_to root_path }
format.js {}
end

my index page delete link

<%= link_to admins_manage_client_path(owner), method: :delete,id: owner.id, remote: true, class: "btn btn-danger" do %>

<% end%>

         my server logs

         Started DELETE "/admins/manage_clients/12" for 127.0.0.1 at 2017-03-12 10:55:37 +0530

Processing by Admins::ManageClientsController#destroy as JS
Parameters: {"id"=>"12"}
Geokit is using the domain: localhost
User Load (0.6ms) SELECT users.* FROM users WHERE users.id = 12 LIMIT 1
(0.1ms) BEGIN
SQL (0.2ms) DELETE FROM users_roles WHERE users_roles.user_id = 12
SQL (0.2ms) DELETE FROM users WHERE users.id = 12
Started DELETE "/admins/manage_clients/12" for 127.0.0.1 at 2017-03-12 10:55:37 +0530
Processing by Admins::ManageClientsController#destroy as JS
Parameters: {"id"=>"12"}
Geokit is using the domain: localhost
User Load (0.3ms) SELECT users.* FROM users WHERE users.id = 12 LIMIT 1
Completed 404 Not Found in 2ms (ActiveRecord: 0.3ms)

ActiveRecord::RecordNotFound (Couldn't find User with 'id'=12):

app/controllers/admins/manage_clients_controller.rb:24:in `destroy'
(56.1ms) COMMIT
Rendering admins/manage_clients/destroy.js.erb
Rendered admins/manage_clients/destroy.js.erb (0.4ms)
Completed 200 OK in 65ms (Views: 2.8ms | ActiveRecord: 57.3ms)

Rendering /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb
Rendering /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_source.text.erb
Rendered /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_source.text.erb (0.7ms)
Rendering /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb
Rendered /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb (0.7ms)
Rendering /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb
Rendered /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb (1.1ms)
Rendered /home/nav/.rvm/gems/[email protected]/gems/actionpack-5.0.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb (15.3ms)

somehow the suggestion from @shakycode solve my issue now my logs does not show double render.

I think my application.html.erb does not have double yield

<% if (current_user && (current_user.has_role? :vendor ))%>

  <%= render 'layouts/vendor_header' %>

<%elsif (current_user && (current_user.has_role? :user))%>
  <%= render 'layouts/user_header' %>
<%else%>
<%= render 'layouts/public_header' %>
<%end %>

    <%= yield %>
    <% if (current_user && (current_user.has_role? :vendor)) %>


  <%= render 'layouts/footer_vendor' %>

<%elsif (current_user && (current_user.has_role? :user))%>
  <%= render 'layouts/footer_user' %>
<%else%>
<%= render 'layouts/footer_public' %>
<%end %>

Processing by Users::HomesController#welcome as HTML
Processing by Users::HomesController#welcome as HTML
Rendering users/homes/welcome.html.erb within layouts/application
Rendering users/homes/welcome.html.erb within layouts/application
Rendered users/homes/welcome.html.erb within layouts/application (14.9ms)
Rendered users/homes/welcome.html.erb within layouts/application (14.3ms)
Rendered layouts/_public_header.html.erb (1.2ms)
Rendered layouts/_public_header.html.erb (0.4ms)
Rendered layouts/_footer_public.html.erb (0.7ms)
Rendered layouts/_footer_public.html.erb (0.2ms)
Completed 200 OK in 24185ms (Views: 24118.8ms | ActiveRecord: 3.4ms)

<%= select_tag "event[#{inquiry.slug}]", options_for_select([ "PENDING", "CONFIRMED" ], inquiry.status), :data => {url: update_status_vendor_inquiry_path(inquiry),method: "put", type: "script", remote: true} %>

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.