In my rail application, I also try to test my call for Redis. For example, in my user model I have:
def to show in self.add_to_visibles user # $ redis.lpush menu ("user_visibles", user.to_json (only: [: vorname : Now that I run this test, the test data is inserted into redis store
This means that when I I am also on the development. I also get this figure."user_visibles"
.That is why I want to change my method:
def self.add_to_visibles user #to $ in menu Show redis.lpush ($ u Ser_visibles, user.to_json (only: [: vorname,: nachname ,: id, created_at]) end
and
$ user_visibles : For testing:
$ user_visibles = "user_visibles_test"
and for production
$ user_visibles = "user_visibles"
Where do I place this variable best? And how is it different for the environment?
I do something like this:
config / user_variables.rb
Rails.configuration.user_variable = YAML :: load_file ("# {Rails.root} / config / User_variables.yml ") [Rails.env]
and thus created config / user_variables.yml
Product: 'user_visibles' test: 'user_visibles_test'
Remember to restart your server
Get value with .configuration.user_variable where you need it
No comments:
Post a Comment