Enviornment in rails

By default 3 enviornments ::

Development, test, productio 

........................... 

Types of enviornments ::

1. Development: first env

2. Testing: second env

3. Staging: third env

4. Production: fourth env 

........................................... .............................................

Rails has a configration file in ::

config/application.rb

Links ::

https://nts.strzibny.name/creating-staging-environments-in-rails/

https://dev.to/flippedcoding/difference-between-development-stage-and-production-d0p

............................................... 


Development :: at local computer can share

Staging ::  copy  of production env, before go to production can check test the server data

Production :: production enviornment at main  server this is totally live,no excuses for mistakes


How to create staging enviornment ::

1. Include code for staging  in database. yml

2. Create config/ enviornments/ staging . rb  and copy the code of production. rb Or write below codecode::

if Rails.env.development? || Rails.env.staging?
  require 'rack-mini-profiler'

  # Initialization is skipped so trigger it
  Rack::MiniProfilerRails.initialize!(Rails.application)

  # Needed for staging env
  Rack::MiniProfiler.config.pre_authorize_cb = lambda { |env| true }
  Rack::MiniProfiler.config.authorization_mode = :allowall
end

3.Add the below key in config/secrets.yml ::

Write the command  -- $   rake secrets 

4. Add the staging enviornment by the below command  ::

RAILS_ENV=staging rake db:create

,,..............,,................,,..... 

Included environments

test is designed for running tests/specs. This database will likely be bare bones, except for seeds you may call before running the suite. After each test is complete, the database will rollback to its state before the test began. I do not recommend launching rails server, as running tests (via MiniTest or RSpec) will do this for you, and close the server once the suite is finished.

development allows you to "test" your app with a larger database, typically a clone of production. This allows you to test actual real-world data without breaking production (the version that customers or end-users will experience). To view the development environment in action, change the RAILS_ENV and launch rails server. This is good for deciding how you want your pages to look (CSS, HTML). It is also good practice to briefly "test" your app yourself, clicking around making sure everything "looks" good and the JavaScript works.

production is reserved for the customer and end-user. Configuration includes the actual domain of the app, which ports to use, and initializers or tasks to run. You do not want to play around with your database, as it may be customer-impacting. Ideally, the app should work as best as it can, since this is considered your "final product."



Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5