Answer the question
In order to leave comments, you need to log in
String generation without using callback?
Good time of the day. I want to generate a line without using callbacks in the model.
I decided to create, for example, a link directly in the controller, in the new method:
def create
@user = User.new(link: SecureRandom.urlsafe_base64[0..9])
if @user.save
render json: @user, status: :created
else
render json: { errors: @user.errors }, status: :unprocessable_entity
end
end
rails db:reset
link can't be blank
Answer the question
In order to leave comments, you need to log in
db:reset
removes all tables from the database, creates them according to the schema and starts the seeds.
I propose to see what is happening in the seeds.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question