Я пытаюсь заставить жемчужину Wicked Wizard работать в моем приложении Rails. Как только пользователь регистрируется в приложении (используя Devise), он перенаправляется на эту форму:
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 %>
Я сгенерировал контроллер с именем finances_welcome_controller.rb
, который обрабатывает wizard_path
:
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
Когда я нажимаю кнопку submit
, я получаю эту ошибку:
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 была успешно реализована в этом приложении.