In ruby, one can write multiple codes to remove multiple blank spaces inside strings (sentenses) "Write your string here ".squeeze.strip"This is my input string ".gsub(/ +/, ' ')"Write your string … Continue reading How to remove extra spaces in ruby strings
blog
Manual active record db connection in ruby using mysql adapter
Here is the code to make manual connection with database require 'active_record'ActiveRecord::Base.establish_connection( :adapter => "mysql", :host => "localhost", :username => "root", :password => "abcd", :database => "funonrails" )Load database configurations from yml file dbconfig = YAML::load(File.open('database.yml'))ActiveRecord::Base.establish_connection( dbconfig )
Writing rake task in rails with namespace, parameters
Rake tasks itself defines that “they are bunch of ruby code that performs some task.”Rake tasks are placed in lib/tasks directory of application and files have .rake extension.There are many lovable tasks defined in rails. read moreRake tasks are executed from console.Benefit of writing rake task areTesting of codeScheduled rake tasks ( backgroundRb and scheduled … Continue reading Writing rake task in rails with namespace, parameters
