Sunday, 5 March 2023

Easiest way to understand git rebase and git merge

 Git merge is like combining two different recipes to make a delicious new dish. When you merge two branches in Git, you bring together the changes from each branch and create a new branch that contains both sets of changes. It's a great way to collaborate with others and build something better together.


Git rebase is like renovating your home to make it more modern and efficient. When you rebase a branch in Git, you take all the changes in one branch and apply them on top of another branch. This makes the history of your project easier to understand and can help you avoid conflicts down the line.


Monday, 7 June 2021

How Ruby method lookup works?

 When we call a method on an object, Ruby looks for the implementation of that method. 

 It looks in the following places and uses the first implementation it finds:

  1. Methods from the object's singleton class (an unnamed class that only exists for that object)
  2. Methods from prepended modules (Ruby 2.0+ feature)
  3. Methods from the object's class
  4. Methods from included modules
  5. Methods from the class hierarchy (superclass and its ancestors)



class Superclass

  def monk
    puts "rormonk Superclass"
  end 

end


module IncludedModule

  def monk
    puts "rormonk Included module"
    super
  end
  
end


module PrependedModule

  def monk
    puts "rormonk Prepended module"
    super
  end
  
end

module SingletonModule

  def monk
    puts "rormonk Singleton class"
    super
  end

end

class Klass < Superclass
  include IncludedModule
  prepend PrependedModule

  def monk
    puts "rormonk Klass"
    super
  end
  
end


kl = Klass.new kl.extend(SingletonModule) 
kl.monk

Singleton class

Prepended module

Klass

Included module

Superclass


So when I saw first I extend the class and then call the method than obvious it will call that but later I realize if I will not extend that how would I call that 😅

there will be some people like me who could think superclass is mention in every method due to that it is printing like this 😊 so this is for the super is used to maintain the chain so if you will not put super it will not call the other method and it will just return the first method print value.

✌ 

Tuesday, 26 May 2020

Arvind Vyas: Photos upload in background with combination of ra...

Arvind Vyas: Photos upload in background with combination of ra...: It's easy to upload the photo with rails into the background. But when we talk about a platform like Heroku It uses to be very hard t...

Photos upload in background with combination of rails and HEROKU

It's easy to upload the photo with rails into the background.

But when we talk about a platform like Heroku It uses to be very hard to do this.

Why it is hard to upload a photo into Heroku into the background.

   Limitation of Heroku
    - Temp path can not be the same if you are using multiple dynos.
    - After restarting the application temp path use to change.
    - Application use to start at a particular time interval


How we upload image into the background
- We use to save that into the temp folder and we process that photo into the background  by accessing that temp folder into the background via sidekiq or active job etc. But when we talk about Heroku they don't provide fix temp path than how do we process image ?????


So what we found it we convert the photo into blob / base64 object when someone tried to upload and in the controller, we pass that photos block inside the Redis cache with some key-value pair and we send the request into the background and process that Redis cache into the background and save that image and delete the cache for Heroku.

              If anyone has any issue to understand a comment or mail me I will try to make you guys understand if anyone also has better solution post the link to me or send me.

Ruby on Rails 6 Tutorial: Build your First Rails 6 App



Installing Ruby 2.6.2

You can install Ruby 2.6.2 using RVM.

the following command:

$ rvm install 2.6.2


if you want you can create gemset with the command 

rvm gemset create rails6proj
rvm use gemset rails6proj


Install bundler gem to bundle the gems

gem install bundler


Than you can create rails 6 project with the below command


$ rvm install 2.6.2 


$ rails _6.0.3.1_ new my_first_rails6_proj





the above commands teach us if i want to create new rails version application than I just need to pass the version of rails app

rails _version_ new yourappname 

than
cd my_first_rails6_proj 

bundle install to install all the gems inside your gemset

now your rails6 project is ready to work





Sunday, 10 November 2019

Credentials in Rails 5.2 and Rails 6 Multi Environment credentials support

 Rails 5.2 - Supports credentials , But Not support Multi Environment

credentials are stored in the file config/credentials.yml.enc

and this file is encrypted by the key located inside
config/master.key.

How to achieve multi-environment feature in rails 5.2 is



module YourAppModule
  class Application < Rails::Application
    def credentials
      if Rails.env.production?
        super
      else
        encrypted(
          "config/credentials.#{Rails.env.downcase}.yml.enc",
          key_path: "config/#{Rails.env.downcase}.key"
        )
      end
    end
  end
end

Monday, 14 January 2019

Spree Vs Shopify

What is Spree:-


Spree Commerce is an open-source e-commerce solution based on Ruby on Rails. It is designed to make programming commerce applications easier by making several assumptions about what most developers need to get started It was created by Sean Schofield in 2007 and has since had over 750 contributors and over 747 thousand downloads from RubyGems.



What is Shopify:-


Shopify is a complete-commerce solution that lets you start and manage a business. It lets you organize your products, customize your storefront, accept credit card payments, tracks and respond to orders — all with a few clicks of the mouse.







1. Totally Free


  Spree Commerce is a completely free open source project. Anyone can do customize the code. It has more than 700 active contributors all over the world. The platform develops rapidly (even more rapidly than other commercial projects) and effectively utilizes the demands of the ever-changing market and its users.

2. Highly Customizable

  Spree commerce development allows you to personalize the user experience by installing various customizations on your online store. The large community of ruby on rails developers has created extensions that offer flexibility and optimize performance even when a lot of features are added to the store.

3.  Scaling Capability

  Can handle a huge amount of traffic with an almost negligible increase in response time. It can support over 30,000 products and still manage to provide fast & easy access to the site.

4. Easy Order processing


  When you launch the store, you will spend much time in its backend managing orders, customers and payments. Spree Commerce provides an easy and fast management system. You will be amazed at the simplicity and functionality of the dashboard.

5. Mobile Friendly

  Today, building e-commerce applications are only effective if it is mobile friendly. Spree commerce stores are compatible with any mobile device on any operating system. The design elements don’t slow the response time and offer a quality experience.

6.  Flexible API

  With spree commerce, integrating a third-party application becomes simplified. A flexible API allows developing new applications and will drastically enhance your store capabilities with added features.

7.  Awesome Community

    - Helping the community any queries it has slack and Google emails in which peoples are active.





   Shopify gives you 14 days free trial to have personal experience with them. So then you can try Shopify platform at least once if they are planning to start an e-commerce business. click here for pricing.

    Already build themes which you can integrate and use asap and showcase your product to the user. 
  you can save your designer cost and you can use other's mind of design your organization does not have that capability to think.

  3. 100+ Payment Gateways

    Multiple payment gateways already build with plugins so you can easily set it up. what you need is just create the payment account and shared it with Shopify dev they will setup it up for you.

  4. Integrate with Shipping

    Multiple shipping partners can be added with the use of plugins. so you can save testing time and development time of integration of it if you go with the self-hosted application.

  5. Hosted Solution

    You need not to worry about your application like uptime, user traffic you can save your IT team cost which you need for a self-hosted application.

  6. Gift cards

    You can also issue a gift-card to customers for free as a reward for using your store. Your customer can use the gift card to make a purchase from your store both online and in person.



Conclusion:- 


When to use spree:-

1. You want to rapidly upgrade your online store (thanks to the Ruby on Rails framework).
2. You want to avoid paying additional fees.
3. You want to customize your store in various ways.
4. You like the fact it’s easier to optimize your shop’s performance (website loading speed for users and Google bots)
5. Most you have a people who can think to make your application better without copying anything from other web apps which make your application more beautiful and attractive.
6. If you are looking for multi-currency and set product price in a different currency and took payment.


When to use Shopify:-

1. You want to sign up and have an eCommerce store launched in a quick manner.
2. You don’t want to learn any technical details of your eCommerce platform.
3. You’re in a drop shipping business with Amazon, Shipwire, or Rakuten. Shopify comes with dedicated solutions for these platforms.
4. If you have people who are good at updating content rather think about the product design and development.
5. If you don't want multi-currency setup only happy with local currency.
7. If you are ready to pay for every new extension you want to use with your app not once but monthly.