Posts

Showing posts from July, 2022

how to rollback a specific migration

 1. go to db / migrations   2. find the specific migration number   3. $   rake db:migrate:down VERSION=20220728103647  4. change in the specific migration   5.  rake db:migrate:up VERSION=20220728103647

how to switch to the new branch in the current working project

1. git checkout master  2. copy the code of database.yml and put at another place in sublime or anywhere  3. git checkout -b workflow  (the new branch) 4. paste the code of  database.yml previously taken in the database.yml  4. git pull origin master  5. close the database.yml  6. git pull origin master 

how to check all branch in git

 git branch -a 

scope banana

  r sir  - igb project mein scope hi scope banaye the humne  project tha 

academic year in acdemic class code in project skoolfinance 21 k hrms

  show do     attributes_table do       row :name       row :academic_year do |object|         if object&.academic_year.present?           link_to object&.academic_year&.year, "/admin/academic_years/#{object&.academic_year&.id}"         end       end     end     panel 'Academic Class' do       attributes_table_for academic_class.divisions do         row :id         row :title       end     end   end

active admin nested form

 https://activeadmin.info/5-forms.html

new task at seed.rb

 arvind sir discussion at meeting and rinku sir solve he ask  get the link from builder cd  pipeline  copy the line from seeds.rb chingching and paste it to console create api inside account controller   - accounts_controller.rb  def create_active_admin end creae roe for his mehod a roes.rb  postman par reqest bheji hai  before action except filrter lagaya 

Active Admin by Rails

 https://activeadmin.info/

some rails concepts

 self.abstract_class = true ............................................................. require 'csv' ............................................................. csv ==  comma seperated values 

how to login posrgres at your system

 psql -U postgres .................................................. generally there are two passwords of the postgres : root postgres  ... we can check the postgres password also 

Error :: StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "users" already exists

Error :: StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: table "users" already exists ................................................................................................................................................ 9 just run into the console rails console and type in ActiveRecord::Migration.drop_table( :users ) and then exit the console and rake db:migrate This method is successful :: this will work definately 51 If you create an empty migration by running: rails g migration DropInstalls or: rails generate migration DropInstalls You can then add this into that empty migration: class DropInstalls < ActiveRecord::Migration def change drop_table :installs end end Then run  rake db:migrate  in the command line which should remove the Installs table Note:  db/schema.rb  is an autogenerated file. To alter the db structure, you should use the migrations instead of attempting to edit th...

remove column in rails

 class Removeemailfromusers < ActiveRecord::Migration[6.0]   def self.up      remove_column :users, :email, :string   end   def self.down      add_column :users, :email, :string   end end

add column in rails

  Use this command on the terminal: rails generate migration add_fieldname_to_tablename fieldname: string and rake db: migrate rails generate migration add__to_tablename fieldname: string

add column in rails in schema table after an existing column

class AddDobToCustomer < ActiveRecord::Migration [ 5.2 ] def change add_column :customers , :dob , :date , after: :email end end

import export method

 controller ::    def import       csv_data = BxBlockFee::Fee.import(params[:file])       render json: {message: "Fee data is successfully Imported"}, status: :created     end     def export       csv_data = BxBlockFee::Fee.all       respond_to do |format|         format.csv { send_data csv_data.to_csv, filename: "Installment-#{DateTime.now}.csv" }       end     end route ::   namespace :bx_block_fee do     resources :fees, :only => [:index, :create, :update, :show, :destroy] do         post 'import', on: :collection         get 'export', on: :collection     end   end model :: module BxBlockFee class Fee < BxBlockFee::ApplicationRecord require 'csv' self.table_name = :fees validates :name, :valid_until, :amount, presence: true belongs_to :academic_account, clas...

filter method

     def filter       @taxes = BxBlockTax::Tax.all       if params[:name].present?          @taxes = @taxes.where(name: params[:name])       end       if params[:tax_start].present? && params[:tax_end].present?         @taxes = @taxes.where(tax_percentage: params[:tax_start]..params[:tax_end])       end         render json: TaxSerializer.new(@taxes, meta: {message: "Tax lists"}).serializable_hash, status: :ok     end

How to copy paste the code at new branch - at all code

R sir do this 

Import the database given by R sir

Database .yml mein jo bhi name daloge woh application.yml mein bhi set karoge Note :: database.yml aur application.yml mein change krna hoga database import - i have to import new database which is given by rinku – that is local database 1. first the file given by rinku – download that 2. cut paste that to the normal folder of chingching 3. change the database name in application.rb and database.yml - ........................................................................................................................................ In database.yml - database: 'chingchingbyakon_dev1' , test - database: 'ChingChing_test1' ........................................................................................................................................ in application.yml - development - database: 'chingchingbyakon_dev1', test - database: 'ChingChing_test1', production: ‘chingchingbyakon_dev1’ ...........................................................

create full module in the project

 1 give command model - rails g model FeeConcession fee_concession_id:string fee_concession_name:string valid_until:datetime fee_concession_amount:decimal mode:string  2 create route.rb -   namespace :bx_block_academic_account do     resources :academic_account   end 3 create controller - module BxBlockAcademicClass   class AcademicClassesController < ApplicationController     before_action :current_user     before_action :set_academic_class, only: [:update,:show, :destroy]     def index       academic_classes = AcademicClass.order("created_at DESC").paginate(page: params[:page], per_page: 10)       if academic_classes.present?         render json: AcademicClassSerializer.new(academic_classes, meta: {total_pages: academic_classes.total_pages, message: "Academic class lists"}).serializable_hash, status: :ok       else         render json...

if rake db:migrate do not run then command to run

 bundle exec rake db:migrate 

If delete any table from schema and the table is not delete then what will happen

rake db:drop delete all migration files manually delete all other folders and files  rake db:create rake db:migrate  pull from another branch