gem install bundler:1.12.5
Thursday, 3 December 2020
Thursday, 27 August 2020
Generate Dynamic File with Content in rails
EmailTemplate.where("locale = 'de'").each do |et|
body = et.body
File.open("templates/#{et.slug}.html", 'w+') {|f| f.write(body) }
end
Tuesday, 18 August 2020
set root password in mysql for root user
~$ sudo mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '
root
';
mysql> exit
$ mysql -u root -p
$ Enter Password: root
Tuesday, 4 August 2020
Avoid N+1 Queries
1 . Location.includes(:users).where(users: {username: "ashish"})
Lead.includes(:contacts).where("contacts.primary" =>true)
2. Person.includes(notes: [:grades]).where(notes: {important: true, grades: {important: true})
3.
class Person < ActiveRecord::Base
has_many :notes
has_many :important_notes, -> { where(important: true) }, class_name: "Note"
end
Person.preload(:important_notes)
4.
Person.eager_load(:notes)
Subscribe to:
Posts (Atom)
Revert last commit or second last and more....
Git revert commit_id -m 1 this command willl revert last commit Git revert commit_id -m 2 this command will revert second commit with same...
-
1. step : <script type="text/javascript"> window.onload = function(){ //Check File API support if(...
-
def time[A](f: => A) = { val s = System.nanoTime val ret = f println("time: " + (System.nanoTime - s) / 1e9 + ...
-
1. Add gem "aws-sdk-s3" and bundle install require 'aws-sdk-s3' # AWS S3 bucket upload method def self.upload...