0

I have a web application with Rails 4 where you have to log in to use it. Now I want a demo version of this app. By demo version I mean a version that has all the features of the original app but without the login. And all the demo data should (and can easyliy) be deleted from time to time (either automatically or manually).

With the original app up and running I want to implement the demo version with the least effort. Ideally I can use most of the original code without any changes. But changes to the original code on the other hand will be available in the demo version without any extra work.

My first idea was to implement the demo version just in the cache/session so if the session is expired, the data is deleteded as well. I canceled that idea due to the deep integration of ActiveRecord in the original app. I would have to re-code all the demo classes and/or build some abstract parent classes and so on.

The second idea was to simply use the original app but to add a flag to each demo account so that they can be distiguished from all the regular ones. I hesitate with this idea because I'm afraid to blow up my database (i.e. the tables that I use for the original app) with demo data leading to lower performance and higher cost/risk of wrong interpretations when evaluating the app data (e.g. how many accounts where created yesterday).

Do you have any ideas how to realize such a demo version in an elegant way? Smart approaches welcome!

user2148956
  • 179
  • 1
  • 1
  • 10

2 Answers2

1

You can have a Guest user account, and a before action in ApplicationController that checks if the current application is in demo mode (specifiable through a custom config) and automatically logs in the user.

You can use a cron job to delete the demo data. Whenever is a good solution for managing cron jobs in ruby.

Community
  • 1
  • 1
lorefnon
  • 12,875
  • 6
  • 61
  • 93
  • Yes, I think generating an account with a demo flag is the best solution. A cron job will delete all old demo accounts. This will definitely complicate statistics (because I will have to filter out all demo accounts) but I will save a lot of redundant code and effort to implement a separate demo version of the app. – user2148956 Feb 17 '17 at 12:43
0

for automated fake data creating use whenever and faker gems. Faker will generate fake data. Whenever for cron job. And after every demo session it will clear the mock data.

take these point : session, cron, fake seed data

Mahabub Islam Prio
  • 1,075
  • 11
  • 25