내 Rails 앱에서 작동하는 Wicked Wizard 보석을 얻으려고합니다. 응용 프로그램 (고안를 사용)에 대한 사용자 등록되면, 그들은이 형태로 리디렉션하고 있습니다 :배열에 대한 정의되지 않은 메소드`update '
:income.html.erb
<%= form_for @finance, url: wizard_path, :method => :put do |f| %>
<div class="field">
What <strong>year</strong> were you born?<br>
<%= f.number_field :age %>
</div>
<div class="field">
What's your <strong>zip code</strong>?<br>
<%= f.number_field :zip %>
</div>
<%= f.submit %>
<% end %>
나는 wizard_path
을 처리 finances_welcome_controller.rb
라는 컨트롤러를 생성
submit
버튼을 클릭하면
class FinancesWelcomeController < ApplicationController
before_filter :authenticate_user!
include Wicked::Wizard
steps :income, :expenses
def show
@finance = Finance.find_all_by_user_id current_user[:id] || @finance = current_user.finances.build(finance_params)
render_wizard
end
def update
@finance = Finance.find_all_by_user_id current_user[:id]
@finance.update(params[:finance])
render_wizard @finance
end
것은,이 오류를 받고 있어요3210
NoMethodError in FinancesWelcomeController#update
undefined method `update' for #<Array:0x00000104c6ff48>
Extracted source (around line #14):
def update
@finance = Finance.find_all_by_user_id current_user[:id]
**@finance.update(params[:finance])**
render_wizard @finance
end
내 리소스 모델에서 사용하는 구문과 동일하므로 업데이트 방법이 정의되지 않은 이유를 잘 모릅니다. Wicked Wizard gem이 this app에 성공적으로 구현되었습니다.
감사 : ID가 ... 난 그렇게
find_by
로 변경 권 해드립니다. 내 사용자가 재무와 관련되어 있고 Finance를 편집하기 위해 _form을 눌렀을 때 마법사에서 제출 된 데이터로 데이터가 업데이트되지 않습니다. – beaconhill@beaconhill - 'update_attributes'를 시도하십시오. 또는 이상적으로는 @finance.assign_attributes (params [: finance]); finance.save!' – BroiSatse
실제 재정 편집 페이지 (/ finance/6/edit)에있을 때 마법사 페이지 (/ finance_welcome/양식의 일부인 소득)로 돌아갈 때 절약됩니다 – beaconhill