V
V
Vayladion Gognazdiak2018-10-19 12:14:31
Ruby on Rails
Vayladion Gognazdiak, 2018-10-19 12:14:31

Is there an analogue of strong params inside the model?

Good day,
Actually, the subject is interested in not getting ActiveModel::UnknownAttributeError: unknown attribute .
Modelka: Actually, you have to do this:
Match id: nil, home_team: nil, away_team: nil

hash = {home_team: "Мясо", away_team: "Бомжи", third_team: "Лохомотив"}
Match.create(hash.reject{|t| !Match.attribute_method?(t)})

but I think there is an easier way

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question