Building a Story App in Rails

Mikey_Gnote Source

I am building a collaborative story app in rails. It is a simple application that will have a User controller, a story controller, then a model for each along with a join table story_user.

Users will be able to start a new story or add to an existing story created from another user.

I'd like to put the users in groups according to age. For ex: 5 - 9, 10 - 13, 14 - 17, 18+. So, only appropriate stories appear for the current_user.

I know I have to use a validation for birth_date but I'm not sure how. Also, can I change the styling of the story show page based on the age of my user? If so, where would that 'if' statement go in the rails folder structure?

Thanks in advance.



answered 6 months ago Elis Bresciani #1

You can create the categories as an enum, and use the cancancan gem for permissions.


enum category: {
  "5-9": 0,
  "10-13": 1,
  "14-17": 2,
  "18+": 3

and then in your view you validate whether it can or not see.

comments powered by Disqus