Answer the question
In order to leave comments, you need to log in
What does the RubyMine warning mean: controller action should call one model method other than an initial find or new.?
The controller has a method:
def create_country
@country = Country.new(country_params)
begin
#сохраняем модель
@country.save
#это метод другой модели
CountryTvText.create_or_update_for_country @country.id, params[:country_tv_text]
flash[:notice] = "Страна добавлена"
rescue Exception => e
flash[:error] = e.message
end
redirect_to admin_panel_path
end
@country.save
CountryTvText.create_or_update_for_country @country.id, params[:country_tv_text]
Answer the question
In order to leave comments, you need to log in
Don't do this in the first place:
And after you rewrite it to something like
if @country.save
...
else
...
end
controller action should call one model method other than an initial find or new
This is a warning that you are using more than one model method in a controller.
Read "Rails best practices"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question