0

I trying rewrite some data in model. Change_settings is GET-method, update_settings is POST. After click SUBMIT happens nothing. Data not change. Help me, please( what's wrong?

controller

  def change_settings
    @vacation_days = current_company.vacation_days
    @illnes_days = current_company.illnes_days
  end

  def update_settings
    current_company.update_attribute(:vacation_days, :illnes_days)
    current_company.save
    redirect_to account_company_path, notice: t('company.settings_changed')
  end

change_settings view

.company_settings
  = form_tag update_settings_company_path do
    = field_set_tag do
      = label_tag 'vacation_days'
      = text_field_tag :vacation_days
      = label_tag 'illnes_days'
      = text_field_tag :illnes_days
      %br
      = submit_tag t('common.save'), class: 'btn'
      = link_to t('common.back'), account_company_path, class: 'btn' 

routes

resource :company, only: :all do
    get :account        
    get :change_settings
    post :update_settings
  end
4

1 回答 1

0

代替:

current_company.update_attribute(:vacation_days, :illnes_days)
current_company.save

和:

current_company.update_attributes(vacation_days: params[:vacation_days], illnes_days: params[:illnes_days] )

基本上你没有考虑从客户发送的数据

于 2013-09-25T15:01:10.747 回答