0

I'm new to ruby on rails

I'm modeling the entity "GenericUser" for my web app; I should generate it using scaffolding specifying many attribute : username and email (the primary key of the database table), FirstName, LastName, Gender, and other attribute that could take different value, for example MusicianRole could be "guitarist", "drummer" etc that the user could choose at the registration

The question is: How should I have to specify the type of all these attributes correctly?

1 Answers1

0

You can write this in the command line :

rails generate scaffold Post username:string email:string firstname:string gender:string ...

and for the primary key you can find answer here :

how to add a primary key to a table in rails

Community
  • 1
  • 1
Antonin Mrchd
  • 199
  • 1
  • 1
  • 15
  • ok but my problem is the type of the variables... is there a specific type for the email? and also for attribute who could take different values? –  Dec 21 '16 at 20:53
  • @RobertoCaravelli email is a string, there is not a specific type. What do you mean by "attribute who could take different values ?" – Antonin Mrchd Dec 21 '16 at 20:56
  • In my app, the GenericUsers have to specify what kind of musician they are, for example drummer/guitarist/bassist etc..... –  Dec 21 '16 at 21:00
  • @RobertoCaravelli a musician can have multiple type ? – Antonin Mrchd Dec 21 '16 at 21:03
  • I think that this post should help you : http://stackoverflow.com/questions/18691253/ruby-on-rails-saving-multiple-values-in-a-single-database-cell – Antonin Mrchd Dec 21 '16 at 21:05
  • When users register in my app with a form, I show them different choice for the musician type, but probably I should model this parameters like a simple string –  Dec 21 '16 at 21:11
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131192/discussion-between-roberto-caravelli-and-antonin-mrchd). –  Dec 21 '16 at 21:14