I am trying to migrate subject_id and course_id to the users table by typing:
rails generate migration add_course_id_and_subject_id_to_users course_id:integer, subject_id:integer
However, it results in the error:
_add_course_id_and_subject_id_to_users.rb:4: syntax error, unexpected tSYMBEG, expecting keyword_do or '{' or '('
Not sure why this is happening.
This is shell syntax, not Ruby syntax, so you need to drop the comma between you attribute defs:
rails generate migration add_course_id_and_subject_id_to_users course_id:integer subject_id:integer
With the comma, you're trying to add two fields, "course_id:integer," (comma!) and "subject_id:integer" with the types "integer," (comma!) and "integer", respectively.
Somewhere along the road, the generated Ruby code will have that syntax error and raise the exception.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With