Topic: is the a better way of adding a user into nested attributes?
I have attachments that has many uploads (files), so it accepts nested attributes for uploads on the attachment form so they are sent using the uploads_attributes, everything ok, everything working. BUT I need to assign a user to that upload, the user that uploaded the file, the current user, until now I assign the user using this line before creating the attachment inside the create method of the attachment controller
params[:attachment][:uploads_attributes]["0"][:user] = current_user @attachment = @project.attachments.new(params[:attachment])
["0"] becouse I allow only one upload at the beginning so Im sure there will be only one upload when the attachment is created.
The thing is
params[:attachment][:uploads_attributes]["0"][:user] = current_user
is a realy ugly line, is there a way to make it look better? more Rails way?