0

I'm working on a survey application where i need to display and save the data filled in during the survey at the end but there are no users(e.g. devise) since you can't login.

Example of survey:

Whats your name? 
-- [input]

Example of show page:

Hi there [input], here are your results:

I tried saving [input] in the session but that way the data will be lost after the session ends and i want to keep the data in a database.

Tried googling for a few hours but no real answers to this question. How can i go about this problem, any help in the right direction would be much appreciated.

luissimo
  • 916
  • 2
  • 10
  • 31
  • 1
    it's not necessary to have a user system to use a database. In fact "users" are just another table in the database you have the freedom to add, similar to any other data. Read up on the model layer in Rails, it's built in and there are plenty of tutorials on it. – max pleaner Jun 13 '17 at 19:59

1 Answers1

1

You should just save the session data regardless of any user model. You mention the session would be lost, but you can easily save it to the database after they're done with the form. There's no reason the session needs to be associated with a user. The following are some resources:

Rails: How to store data in session?

Can I use sessions/cookies in Ruby on Rails without having a user's model or any authentication?

How Rails Sessions Work

tmarkiewicz
  • 515
  • 5
  • 12