Posts

Showing posts from May, 2018

CURL COMMAND ON RUBY ON RAILS

HOW TO USE CURL ON RUBY ON RAILS? LIKE THIS ONE curl -d 'params1[name]=name&params2[email]''http://mydomain.com/file.json' Just in case you don't know, it requires 'net/http' require 'net/http' uri = URI.parse("http://example.org")

RUN RAILS SERVER ON PORT 443

If we want to run the rails application in port 443 :- I have added the below line in /config/environments/production.rb: config.force_ssl =true Now I have tried the below attempts: Start rails on 3000 SSL=true rails s -e production -p 3000 It runs rails on https://project.com but 404 error on http://project.com Start rails on 443 and mentioned the same port in script:

AUTOCOMPLETE WITH AJAX IN RAILS

Image
Autocomplete with Ajax in rails index.html.erb page:-  <%= f.text_field :store_name, id: "store_shop" %>
controller :-class StaticController < ApplicationController
  def index; end

  def search
    if params['search'].size > 2
        result = search_shop(params['search'])
      found  = result.present? ?  result.map{|x| x["name"]} : result
      render :json => found
    else
      render :json => []
    end
  end
end
javascript :- // calling the third api from autocomplete
<script>
  $(function() {
    function log( message ) {
      $( "<div>" ).text( message ).prependTo( "#log" );
      $( "#log" ).scrollTop( 0 );
    }

    $( "#
store_shop" ).autocomplete({
      source: function( request, response ) {
       $.ajax({
          type: "get",
          url: "/static/brewery/",
          data: { search: request.term },
          dataType: "json",
          success: function…

psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

If we are getting error after creating database in postgres like this :-psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? Then use following link :- https://stackoverflow.com/questions/42653690/psql-could-not-connect-to-server-no-such-file-or-directory-5432-errorsudo chmod 777 -R /var/run/postgresql/Then restart the postgres:-  sudo service postgresql restart orsudo systemctl start postgresql@9.6-main