Posts

RAILS: UPLOADING PHOTOS VIA AMAZON S3 AND PAPERCLIP (UPLOADING FILES TO S3 IN RUBY WITH PAPERCLIP)

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 Modelclass User < ActiveRecord::Base
    has_attached_file :image, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png"
      validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
end
Migration…

AWS EC2 INSTANCE, ASSOCIATE ELASTIC IP, RDS AND ELASTIC BEANSTALK

IF WE WANT TO CREATE EC2 INSTANCE and MAP WITH ELASTIC IP OR WANT TO CREATE RDS and DEPLOYMENT WITH ELASTIC BEANSTALK : -SO THESE BELOW LINK WILL HELP YOU 
Now I have tried the below attempts:

    1.  Increase EC2 Instance RAM :-       https://www.youtube.com/watch?v=YCI5sehyDNc


    2.  Map with elastic IP :-       
https://www.youtube.com/watch?v=mgfpduy5ZAo
https://www.youtube.com/watch?v=A3F2vIQYlu8


    3.  Difference between Elastic IP, Public IP and Private IP: 
https://www.youtube.com/watch?v=MTBR9jyD5RM
    4.  AWS Instance Pricing :- https://aws.amazon.com/ec2/pricing/on-demand/
    5.  How to Assign Multiple IPs to one EC2 Instance                                                                                
https://www.youtube.com/watch?v=Hd05tEuTv-E
    6.   Create RDS database in AWS :- 
https://www.youtube.com/watch?v=I9Fzm1obG7U
    7.   Elastic Beanstalk :-                                                                                                                            
h…

RECURRING PAYMENT IN STRIPE, SUBSCRIPTION PAYMENT IN STRIPE RAILS

Image
Using Recurring Payment (Subscription Based)  RailsQuickly integrate Recurring payment into your Ruby on Rails-based site to provide your users with a streamlined, mobile-ready payment experience.Getting startedThe first step is adding the Stripe gem to your application’s Gemfile:gem 'stripe'

Then, run bundle install to install the gem.

https://dashboard.stripe.com/account/apikeys


Create config/initializers/stripe.rb:

Rails.configuration.stripe = {
  publishable_key: Rails.application.secrets.stripe_publishable_key,
  secret_key:      Rails.application.secrets.stripe_secret_key
}

Stripe.api_key = Rails.configuration.stripe[:secret_key]


We will use testing keys for the development environment. For production environment you need to configure with live keys to receive real payments.

Add these keys at config/secrets.yml:

development:
  stripe_publishable_key: pk_test_xxxxxxxxxxxxxxxxxxxxxxxx
  stripe_secret_key: sk_test_xxxxxxxxxxxxxxxxxxxxxxxx

production:
  stripe_publishable_key: ENV[…

STRIPE IN RAILS, CHECKOUT PAYMENT WITH STRIPE IN RAILS

Image
Using Checkout and Rails Quickly integrate Checkout into your Ruby on Rails-based site to provide your users with a streamlined, mobile-ready payment experience. Getting started The first step is adding the Stripe gem to your application’s Gemfile:gem 'stripe' Then, run bundle install to install the gem. Create config/initializers/stripe.rb:Rails.configuration.stripe = {
  publishable_key:  Rails.application.secrets.stripe_publishable_key,
  secret_key:          Rails.application.secrets.stripe_secret_key
}

Stripe.api_key = Rails.configuration.stripe[:secret_key]


We will use testing keys for the development environment. For production environment you need to configure with live keys to receive real payments. We can create the Stripe api keys from :- https://dashboard.stripe.com/account/apikeys Add these keys at config/secrets.yml:development:
  stripe_publishable_key: pk_test_xxxxxxxxxxxxxxxxxxxxxxxx
  stripe_secret_key: sk_test_xxxxxxxxxxxxxxxxxxxxxxxx

production:
  stripe_publishab…

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: