Posts

Showing posts from September, 2022

connect multiple databases in the rails 6

https://medium.com/@paulndemo/using-multiple-databases-in-ruby-on-rails-316f9040fc6e

concerns

 https://dev.to/software_writer/how-rails-concerns-work-and-how-to-use-them-gi6#:~:text=A%20Rails%20Concern%20is%20a,including%20class%20can%20use%20them.&text=The%20code%20inside%20the%20included,context%20of%20the%20including%20class.

Rspec :: Additions

 1. Uncomment following line from  rails_helper.rb  so all files inside  spec/support  are loaded automatically by rspec # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } Dir [ Rails . root . join ( 'spec' , 'support' , '**' , '*.rb' ) ] . sort . each { | f | require f } 2. Check factory bot rails version inside  Gemfile.lock  and update the gem with that version in  Gemfile . It was  6.1.0  while writing this tutorial, yours may be different depending on latest gem version. group :development , :test do gem 'factory_bot_rails' , '~> 6.1.0' end 3. Add  factories  folder inside  spec  folder if it doesn’t already exist. You can then create factories inside  spec/factories  folder.

Rspec - Rails == Fully certified by dwijendra

Image
 Rspec - Rails == Fully certified by dwijendra  :: ....................................................................................................... 1. Add Gems - Add rspec-rails, factory_bot_rails,simplecov  group :development do   gem 'rspec-rails'   gem 'factory_bot_rails'   gem 'simplecov', require: false end 2. $ rails generate rspec:install Note - This will create these 4 below Files --        create  .rspec       create  spec       create  spec/spec_helper.rb       create  spec/rails_helper.rb 3. in spec folder - create controller models and other folders according to requirement  4.create the coverage folder and index.html   link ::  https://www.youtube.com/watch?v=6qI5JHgYYUE  (youtube link )   Add this in the spec_helper.rb - at the top above  RSpec.configure do |config|   require 'simplecov' SimpleCov.start note - but...

how to learn rails and ruby

 in the old projects everything is mention do that in dummy app and learn and make notes etc .

add multiple id in dropdown in admin side form at browser

Note :  we have to add the multiple email ids in sender receiver cc and bcc in drop down in the admin :::::::::  1.............................................. in this form --    form do |f|     f.inputs do       f.input :name       f.input :sender_email, as: :select, collection: AccountBlock::Account.all.map{|e| ["#{e.name} - <#{e.email}>",e.email]},include_blank: false, :input_html => {:width => 'auto', multiple: true}       f.input :cc_email         f.input :bcc_email        f.input :subject        f.input :description     end     f.actions   end end .................................. use this --- for        f.input :sender_email, as: :select, collection: AccountBlock::Account.all.map{|e| ["#{e.name} - <#{e.email}>",e.email]},include_blank: false, :input_html => {:width => 'aut...

goofd block for ruby interview

 https://launchschool.com/books/ruby/read/intro_exercises https://www.toptal.com/ruby/interview-questions https://www.codecademy.com/resources/blog/10-ruby-code-challenges-for-beginners/

admin add in skoolfiance project

  link -----   https://activeadmin.info/documentation.html    Comand to create the file at the admin side-- $> rails generate active_admin:resource [ MyModelName] url -- http://localhost:3001/admin/invoice_templates/2 1. generate tables - rails g model EmailTemplate name:string created:datetime subject:text description:text rails g model InvoiceTemplate template_name:string date_created:datetime from:string cc:string bcc:string subject:text email_content:text 2. give command – generate this file for admin side $> rails generate active_admin:resource [ MyModelName] 3. add codes in admin files 4. add models 5. done invoice_templates.rb :: ActiveAdmin.register BxBlockInvoiceTemplate::InvoiceTemplate, as: "InvoiceTemplate" do permit_params :name, :created, :sender_email, :cc_email, :bcc_email, :subject, :description actions :all index do selectable_column id_column column :name column :created column :sender_email column :cc_email column :b...

traine wuestions

 how do we conmenmct the rake task for the specific time period  14:48 [Solved]-Rails Execute Cron Job or Rake task for specific time period-ruby https://www.appsloveworld.com every '*/1 09-17   *' do   rake "rake_namespace:rake_task" end every :day, :at => (6..8).to_a.map { |x| ["#{x}:00","#{x}:30", "#{x+1}:00"] }.flatten do   # Run rake task. end LIVE_FOR = 1.hour def run!   finish_before = LIVE_FOR.from_now   array = get_the_array # some big collection to operate on   array.each do |object|     while Time.now < finish_before       ...     end   end end https://www.appsloveworld.com/ruby/100/284/rails-execute-cron-job-or-rake-task-for-specific-time-period

trainer questions

 worker ke thorugh rake task chalaya hai kabhi ?? ans - schdeuler mein likhte hein i think 

tainer question

 koi command hum controller ke trhough chala sakte hein kya ?????????????///

like query in rails

rails 7 features - diff betweem rails 6 and rails7

 https://www.solutelabs.com/blog/ruby-on-rails-7

sto

how to use self in rails

Check the work is done by which user at a special file - when multiple users are available at git with multiple with multiple branches

 git log -p     app/app/controllers/account_block/accounts_controller.rb  git log -p   <filename> note -  file name ---   templateapp/app /app   -no file name  ---  app/app  - no file name ---  app  -yes 

Error -- typeerror no implicit conversion of nil into string in rails site:www.reddit.com

 this error comes when database.yml is wrong in the project  put the right database.yml in the project  after that this error will go 

search good blogs --- for ruby on rails

https://medium.com/@ozhorov/how-to-implement-search-feature-in-rails-and-search-across-multiple-tables-f80b7a3825bb https://melvinchng.github.io/rails/SearchFeature.html#chapter-4-search-feature

add search in rails by simple rails api

   1. add route -----------------------------  namespace :bx_block_fee do     resources :fees, :only => [:index, :create, :update, :show, :destroy] do         post 'import', on: :collection         get 'export', on: :collection         get 'search_fee', on: :collection         get 'search', on: :collection      end 2. add method in controller  -----------------------------    def search       fees = Fee.where('name ILIKE ?', "%#{params[:name]}%").paginate(page: params[:page], per_page: 20)       if fees.present?         render json: FeeSerializer.new(fees, meta: { total_pages: roles.total_pages, message: 'Fee search list' }).serializable_hash,                status: :ok       else         render json: { message: 'No records.' },...

differtence between filter and search

  Filters let you create a list of records that meet a common value.  Search lets you find a single record based on a particular valu

jquyery is running or not

Image
 1. type anything in the field --   name - aaa 2. F12- inspect element -   check elements -   <input type="text" name="user[name]" id="user_name"> 3. Use console -  $("#user_name").val(); 'aaa' at the input  $("#user_name").val(); - ---  output is coming  --  aaa .................. isse yeh check kar liya humne ki jquery lagi hui hai ki nai 

id and class

id and class -  for id  - # for class - .    <div>     <%= form.label :login, style: "display: block" %>     <%= form.text_field :login,class: "ckeditor" %>   </div>   <div>     <%= form.submit %>   </div> <% end %> <script type="text/javascript">   $('.ckeditor').ckeditor({   // optional config }); </script>

check memory in system in ubuntu

free -h 

Active Admin by Self

 https://viblo.asia/p/active-admin-custom-gem-1VgZv9E2KAw note - rails 6 mein error aa rahi thi  rails 7 mein  ho gaya install  

create custom templates in rials

 https://web-crunch.com/posts/how-to-create-custom-scaffold-templates-in-ruby-on-rails https://medium.com/@pratikbh06/customisable-email-templates-in-rails-made-easy-using-panoramic-and-liquid-rails-d1d71f61387d refernece code =--  https://github.com/justalever/scaffold_templates_example imp blog  https://github.com/justalever/scaffold_templates_example email templates imp :::: https://ali-ilman.com/blog/specifying-a-template-and-a-layout-through-action-mailer-mail-function https://ali-ilman.com/blog/specifying-a-template-and-a-layout-through-action-mailer-mail-function mailer with smtp settings ---  https://dev.to/dhintz89/email-and-text-from-rails-5gao https://www.tutorialspoint.com/ruby-on-rails/rails-send-email.htm youtube --  https://www.youtube.com/watch?v=lUFgOiYP9yM order mailer in sending mails  --  https://dev.to/morinoko/sending-emails-in-rails-with-action-mailer-and-gmail-35g4

send_email

 send email in rails --  1. Add letter opener ::   gem "letter_opener" , group : :development Then set the delivery method in  config/environments/development.rb config . action_mailer . delivery_method = :letter_opener config . action_mailer . perform_deliveries = true 2.

uploading with rails

 https://code.tutsplus.com/articles/uploading-with-rails-and-carrierwave--cms-28409

Ckeditor + mailer+ open letter

0. Check the Mail ::::::::::::::::::::::::::::::::::::::::::::::::::::::::: open console - PostMailer.welcome_email.deliver_now or 0. Check with console -- @user = User.last UserMailer . with ( user: @user ). welcome_email . deliver_ now UserMailer . with . welcome_email . deliver_ now ................................................................................ Note ---- Post ko create karna jaruri hai  PostMailer.welcome_email.deliver_now kyunki yahan post create hone ke bad hi yeh method chalega nai toh yeh method nai chalega  ............................................................ 0. /bin.bash--login + rvm use 2.6.5   +   rails -v 1. Webacker error   nvm install v14.10.1 bundle exec rails webpacker:install 2.  Add gems + bundle =            gem 'ckeditor_rails'    =    add ck editor gem - link - https://github.com/tsechingho/ckeditor-rails    ...