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-error sudo chmod 777 -R /var/run/postgresql/ Then restart the postgres:- sudo service postgresql restart or sudo systemctl start postgresql@9.6-main
UPLOADING ANY MEDIA FILE WITH CARRIER-WAVE RAILS Multiple file uploads Add it to your Gemfile: gem 'mime-types' gem 'mini_magick' gem 'rmagick' gem 'carrierwave', '~> 1.0' gem 'carrierwave-video' gem 'carrierwave-video-thumbnailer' gem 'carrierwave-ffmpeg' Run bundle Start off by generating an uploader: app/uploaders/vimeo_uploader.rb rails generate uploader Vimeo Check out this file for some hints on how you can customize your uploader. It should look something like this: class VimeoUploader < CarrierWave::Uploader::Base storage :file end If we want to upload video or image then we will have to use :- class VimeoUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick include CarrierWave::Video include CarrierWave::Video::Thumbnailer include CarrierWave::FFmpeg storage :file de
Country State Select is a library that provides an easy API to generate Country , State / Province and City dropdowns for use in forms. We will refer :- https://github.com/arvindvyas/Country-State-Select Gemfile gem 'chosen-rails' gem 'country_state_select', git: 'git://github.com/arvindvyas/Country-State-Select', branch: :master gem "simple_form"#, "~> 3.2" gem "reform"#, "~> 2.0" gem "reform-rails" orders_controller.rb class OrdersController < ApplicationController def shipping_address @location = Address.new end end shipping_address.html.erb <%= simple_form_for @location, :html => {class: 'subscribe-from'} ,url: orders_shipping_address_path do |f| %> <div class="row"> <div class="col-md-6"> <div class="form-group"> <%= f.input :address_line1, label: "Country", collecti
E: Package 'aptitude' has no installation candidate Sometimes, we are getting broken package error. Please can easily solve this problem. Example:- sudo apt-get install aptitude If you got error like- E: Package 'aptitude' has no installation candidate Solution:- sudo apt-get update sudo apt-get install build-essential sudo dpkg --configure -a sudo apt-get -f install None of those worked in my case. I then went to Ubuntu Software Center>Edit> Software Sources and made these changes. After that the following commands did the job sudo apt-get update sudo apt-get install build-essential sudo apt-get install aptitude Now, problem is solved. Please follow the link below:- http://musingsonsoftware.blogspot.com/2014/02/ubuntu-apt-get-package-has-no.html
Set up Ruby on Rails with Paperclip and S3 using AWS SDK Uploading Files to S3 in Ruby with Paperclip Paperclip requires the following gems added to your Gemfile. If your paperclip version is 5.1.0 then we are using 'aws-sdk' version 2.3. # Gemfile gem 'paperclip' gem 'aws-sdk', '~> 2.3' or our paperclip version is 4.1.0 then we need to use 'aws-sdk' version < 2 (note: add version less than 2.0 otherwise you will get paperclip error) gem 'paperclip' gem 'aws-sdk', '< 2.0' Run bundle install and restart the Rails server after modifying the Gemfile. Then run the command :- rails generate paperclip user image Define the file attribute in the Model class User < ActiveRecord::Base has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png" validates_attachment_content_type :image, cont
Paperclip S3 AccessDenied Aws::S3::Errors::AccessDenied (Access Denied): Assuming you are using AWS’s IAM and you created a dedicated User for these uploads. If you get this error when trying to upload to S3, you need to assign this IAM User the “AmazonS3FullAccess” Policy.
HOW TO USE CURL ON RUBY ON RAILS? LIKE THIS ONE curl - d 'params1[name]=name¶ms2[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" ) # Shortcut #response = Net::HTTP.post_form(uri, {"user[name]" => "testusername", "user[email]" => "testemail@yahoo.com"}) # Full control http = Net :: HTTP . new ( uri . host , uri . port ) request = Net :: HTTP :: Post . new ( uri . request_uri ) request . set_form_data ({ "user[name]" => "testusername" , "user[email]" => "testemail@yahoo.com" }) response = http . request ( request ) render : json => response .body Hope it'll helps others.. :) We can also follow the link below :- https://stackoverflow.com/questions/15804425/curl-on-rub
When we want to use the passenger with Nginx or Apache. Then we need to find the passenger ruby path. So, we can easily find the ruby path using :- passenger - config -- ruby - command When we run then we will get like :- Command: /home/rohit/.rvm/gems/ruby -2.1.10/wrappers/ruby Version: ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-linux] To use in Apache : PassengerRuby /home/rohit/.rvm/gems/ruby -2.1.10/wrappers/ruby To use in Nginx : passenger_ruby /home/rohit/.rvm/gems/ruby -2.1.10/wrappers/ruby To use with Standalone: /home/rohit/.rvm/gems/ruby -2.1.10/wrappers/ruby /usr/bin/passenger start Add that line in passenger.conf file
WHEN WE ENTER , SHOW LINE NUMBER IN TEXT AREA HTML PAGE:- <textarea class="line-numbers" cols="3" readonly="readonly" rows="5"></textarea> <%= text_area_tag :query_editor, '' :name => "query_editor", :class => "add_query_editor" %> <script type="text/javascript"> $(".add_query_editor").keyup(function(event) { $(this).prev().height($(this).height()); $(this).prev()[0].scrollTop = this.scrollTop; }); $(".add_query_editor").keyup(function(event) { var elm = $(this); var lines = elm.val().split("\n"); var numbers = ""; for(var i=0; i<lines.length; i++) numbers += (i+1) + "\n"; elm.prev().val(numbers); elm.prev()[0].scrollTop = this.scrollTop; }); </script> <style type="text/css"> .line-numbers { background-color: aqua text-align: rig
Comments