I trying write params to Company model. But I have error undefined method `model_name' for NilClass:Class in this point = simple_form_for @company, url: update_settings_company_path do |f|. Where I must set @company?
Controller
def change_settings
@vacation_days = current_company.vacation_days
@illnes_days = current_company.illnes_days
end
def update_settings
if @company.update(company_params)
redirect_to account_company_path, notice: t('company.settings_changed')
else
render action: 'change_settings'
end
end
private
def company_params
params.require(:company).permit(:vacation_days, :illnes_days)
end
View
.company_settings
= simple_form_for @company, url: update_settings_company_path do |f|
= f.error_notification
= f.input :vacation_days
= f.input :illnes_days
%br
= f.submit t('common.save'), class: 'btn'
= link_to t('common.back'), account_company_path, class: 'btn'
routes
resource :company, only: :all do
get :change_settings
post :update_settings
patch :update_settings
end
What's wrong? Help me please