Posts

Showing posts from January, 2017

GET /USERS REDIRECT TO USERS/SIGN_IN PAGE

Get /users in the URL then it will be redirect to users/sign_in page.
get '/users', to: redirect('users/sign_in')

RAILS SELECT TAG WITH MULTIPLE VALUES PRE-SELECTED

I am trying to have a multiple select box. select box will contain all the stores in the DB but the ones that the user belongs to will be selected. We can use this :- <%= select("id", "  ", options_for_select(User.all, :selected =>  id ), {:include_blank => 'Please Select'})    %>We can follow link for the same :-https://stackoverflow.com/questions/2196382/rails-select-tag-with-multiple-values-pre-selected

INSTALLING AND UNINSTALLING POSTGRES WITH POSTGIS IN UBUNTU

How to install PostgreSQL 9.6 on any Ubuntu version If we want to install the postgis with postgres then we have to use Postgres 9.6 version. We can follow :-https://askubuntu.com/questions/831292/how-to-install-postgresql-9-6-on-any-ubuntu-version If 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/ After installing postgres 9.6 then we can install the Postgis using :-sudo apt-get install postgissudo apt install postgis postgresql-9.6-postgis-2.3  then we have to add the postgis extension using :-sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" database_namehttp:/…

INSTALLING NGINX + PASSENGER + UBUNTU

Installing Nginx + Passesnger Ubuntu :- 

we will refer this link for installing nginx + passenger :-

https://www.phusionpassenger.com/library/install/nginx/install/oss/xenial/

/etc/nginx/
nginx.conf:-

       user root;
       worker_processes auto;
       pid /run/nginx.pid;

       events {
            worker_connections 768;
       }

       http {
            client_max_body_size 1000M;
            sendfile on;
            tcp_nopush on;
            tcp_nodelay on;
            keepalive_timeout 65;
            types_hash_max_size 2048;

            include /etc/nginx/mime.types;
            default_type application/octet-stream;

           ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
           ssl_prefer_server_ciphers on;

           access_log /var/log/nginx/access.log;
           error_log /var/log/nginx/error.log;

           gzip on;
           gzip_disable "msie6";
include /etc/nginx/passenger.conf;

           include /etc/nginx/conf.d/*.conf;
        …

MAKE AND EXTRACT ZIP FILE

Make the ZIP file:-zip -r filename.zip foldername FOLDERNAME :- whichwewanttomakeinzip WE CAN REFER :-

http://askubuntu.com/questions/58889/how-can-i-create-a-zip-archive-of-a-whole-directory-via-terminal-without-hidden Extract the ZIP file :-unzip filename.zip

WE CAN REFER :-

https://askubuntu.com/questions/520546/how-to-extract-a-zip-file-to-a-specific-folder


COPY A FILE FROM A REMOTE SERVER TO A LOCAL MACHINE AND LOCAL MACHINE TO REMOTE SERVER

Copy a file from a remote server to a local machine?scp username@remote:/file/to/send /where/to/putscp -i /home/test.pem username@remote:/var/deploy/test.rb /home/Desktop Copy a file from a local machine to a remote server?scp /home/Desktop/test.rb username@remote:/var/deployscp -i /home/test.pem /home/Desktop/test.rb username@remote:/var/deployWE CAN REFER :-

https://unix.stackexchange.com/questions/188285/how-to-copy-a-file-from-a-remote-server-to-a-local-machine

UPLOAD ANY MEDIA FILE IN RAILS USING PAPERCLIP

Image
Steps to Upload any type of media in ruby on rails by paperclip Upload video in RailsGemfile

gem 'paperclip'
gem 'paperclip-ffmpeg'
gem 'paperclip-av-transcoder'
Apply validation in modelhas_attached_file :file, :styles => {:medium => { :geometry => "300x300", :format => 'flv'},:thumb => {:geometry => "100x100#", :format => 'jpg', :time => 15}
    }, :processors => [:ffmpeg]

When you will get some validation errors then we can use this below code :-validates_attachment_content_type :file, content_type: %w(video/mp4 video/3gp video/webm image/jpeg image/jpg image/png) Install ffmpeg on your systemsudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg


When we will get some ppa error then run:-

http://stackoverflow.com/questions/29125229/how-to-reinstall-ffmpeg-clean-on-ubuntu-14-04

Play video in rails using video_tag

video_tag("trailer.ogg", controls: true,…