FIGARO:
Purpose of Use.
Figaro was written to make it easy to securely configure Rails applications.
How to impliment .
Step:1>>In Gemfile:
gem 'figaro', '~> 1.1'
Step:2>>$ bundle install or gem install figaro
Step:3>>$ figaro install / rails generate figaro:install
It creates a commented config/application.yml file and adds it to your .gitignore.
Add your own configuration to this file and you're done!
Step:4>>
config/application.yml
DEV_DB_USERNAME: 'xx'
DEV_DB_PASSWORD: 'xxxxx'
DEV_DB_NAME: 'xxxxx'
And here is my database.yml :
development:
adapter: postgresql
encoding: unicode
database: <%= ENV['DEV_DB_NAME'] %>
pool: 5
username: <%= ENV['DEV_DB_USERNAME'] %>
password: <%= ENV['DEV_DB_PASSWORD'] %>
template: template0
AUDITED
Purpose of Use.
Audited (previously acts_as_audited) is an ORM extension that logs all changes to your models.
Audited also allows you to record who made those changes, save comments and associate models related to the changes.
How to impliment .
Step:1>> in Gemfile:
gem "audited", "~> 4.0"
Step:2>> $ bundle install or gem install audited
Step:3>>$ rails generate audited:install
After Step 3 it must create db/20151102092358_install_audited.rb file
if not
Step:1.1>In Gemfile:(add one more gem)
gem 'audited-activerecord', '~> 4.2'
Step:2 & 3
20151102092358_install_audited.rb
-------------------------------------------------------------
class InstallAudited < ActiveRecord::Migration
def self.up
create_table :audits, :force => true do |t|
t.column :auditable_id, :integer
t.column :auditable_type, :string
t.column :associated_id, :integer
t.column :associated_type, :string
t.column :user_id, :integer
t.column :user_type, :string
t.column :username, :string
t.column :action, :string
t.column :audited_changes, :text
t.column :version, :integer, :default => 0
t.column :comment, :string
t.column :remote_address, :string
t.column :request_uuid, :string
t.column :created_at, :datetime
end
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
add_index :audits, [:user_id, :user_type], :name => 'user_index'
add_index :audits, :request_uuid
add_index :audits, :created_at
end
def self.down
drop_table :audits
end
end
------------------------------------------------------------------------------------
Step:4>> $ rake db:migrate
It will create table name 'audits' which will have column
Step:5>> if u want all changes to audited .
class User < ActiveRecord::Base
audited
end
It will store all changes of users into audits table.
EXIFR
Purpose of Use.
EXIF Reader is a module to read metadata from JPEG and TIFF images.
How to impliment .
Step:1>>In Gemfile:
gem 'exifr', '~> 1.2'
Step:2>>$ bundle install or gem install exifr
Step:3>>
now you can get the value & save it in the table you want .
EXIFR::JPEG.new('IMG_6841.JPG').width # => 2272
EXIFR::JPEG.new('IMG_6841.JPG').height # => 1704
EXIFR::JPEG.new('IMG_6841.JPG').exif? # => true
EXIFR::JPEG.new('IMG_6841.JPG').software # => Picasa
EXIFR::TIFF.new('DSC_0218.TIF')[1].width # => 160
EXIFR::TIFF.new('DSC_0218.TIF').model # => "NIKON D1X"
EXIFR::TIFF.new('DSC_0218.TIF').date_time # => Tue May 23 19:15:32 +0200 2006
Purpose of Use.
Figaro was written to make it easy to securely configure Rails applications.
How to impliment .
Step:1>>In Gemfile:
gem 'figaro', '~> 1.1'
Step:2>>$ bundle install or gem install figaro
Step:3>>$ figaro install / rails generate figaro:install
It creates a commented config/application.yml file and adds it to your .gitignore.
Add your own configuration to this file and you're done!
Step:4>>
config/application.yml
DEV_DB_USERNAME: 'xx'
DEV_DB_PASSWORD: 'xxxxx'
DEV_DB_NAME: 'xxxxx'
And here is my database.yml :
development:
adapter: postgresql
encoding: unicode
database: <%= ENV['DEV_DB_NAME'] %>
pool: 5
username: <%= ENV['DEV_DB_USERNAME'] %>
password: <%= ENV['DEV_DB_PASSWORD'] %>
template: template0
AUDITED
Purpose of Use.
Audited (previously acts_as_audited) is an ORM extension that logs all changes to your models.
Audited also allows you to record who made those changes, save comments and associate models related to the changes.
How to impliment .
Step:1>> in Gemfile:
gem "audited", "~> 4.0"
Step:2>> $ bundle install or gem install audited
Step:3>>$ rails generate audited:install
After Step 3 it must create db/20151102092358_install_audited.rb file
if not
Step:1.1>In Gemfile:(add one more gem)
gem 'audited-activerecord', '~> 4.2'
Step:2 & 3
20151102092358_install_audited.rb
-------------------------------------------------------------
class InstallAudited < ActiveRecord::Migration
def self.up
create_table :audits, :force => true do |t|
t.column :auditable_id, :integer
t.column :auditable_type, :string
t.column :associated_id, :integer
t.column :associated_type, :string
t.column :user_id, :integer
t.column :user_type, :string
t.column :username, :string
t.column :action, :string
t.column :audited_changes, :text
t.column :version, :integer, :default => 0
t.column :comment, :string
t.column :remote_address, :string
t.column :request_uuid, :string
t.column :created_at, :datetime
end
add_index :audits, [:auditable_id, :auditable_type], :name => 'auditable_index'
add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
add_index :audits, [:user_id, :user_type], :name => 'user_index'
add_index :audits, :request_uuid
add_index :audits, :created_at
end
def self.down
drop_table :audits
end
end
------------------------------------------------------------------------------------
Step:4>> $ rake db:migrate
It will create table name 'audits' which will have column
Step:5>> if u want all changes to audited .
class User < ActiveRecord::Base
audited
end
It will store all changes of users into audits table.
EXIFR
Purpose of Use.
EXIF Reader is a module to read metadata from JPEG and TIFF images.
How to impliment .
Step:1>>In Gemfile:
gem 'exifr', '~> 1.2'
Step:2>>$ bundle install or gem install exifr
Step:3>>
now you can get the value & save it in the table you want .
EXIFR::JPEG.new('IMG_6841.JPG').width # => 2272
EXIFR::JPEG.new('IMG_6841.JPG').height # => 1704
EXIFR::JPEG.new('IMG_6841.JPG').exif? # => true
EXIFR::JPEG.new('IMG_6841.JPG').software # => Picasa
EXIFR::TIFF.new('DSC_0218.TIF')[1].width # => 160
EXIFR::TIFF.new('DSC_0218.TIF').model # => "NIKON D1X"
EXIFR::TIFF.new('DSC_0218.TIF').date_time # => Tue May 23 19:15:32 +0200 2006
is it possible to help a little bit more as in where you are adding this data? is it the migration file to create database or is it in a model or controller :/ im stuck!
ReplyDelete