Leave "Devise User" untouched?

In general, every registered user should be able to upload as many photos as they want. The user can then share the photos or not.

I have Devise and Active Storage installed. But if I run rails generate model User image:attachment I get an error message.

The name 'User' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative or use --skip-collision-check or --force to skip this check and run this generator again.

I’ve had this problem before and now I want to know:

Should I leave the Devise User untouched and rather use a different name?

like this: rails generate model Uploader image:attachmen

I was once told to leave “devise users” untouched. What do you all mean?

Greeting Tron

If you used the Devise generator to create your User model, then congratulations: you don’t need to create it again. You can add the image column to that model (if you want) by simply running a migration generator. Something like:

rails g migration add_image_to_users image:attachment

Then see what that migration actually looks like (it will appear in db/migrations) and run it with rails db:migrate if it looks correct.

Then you can edit the existing user.rb model file to add the has_attached_image declaration.

Walter

Hello Walter, thanks for your help. Your solution has worked so far. When I search the internet to expand “user devise” this way is described. But I find that rather awkward.

In another topic I described another way with a separate table. But I don’t know if this makes more sense.