在rails 3.0.9和rvm 1.8.7中使用嵌套模型形式的邪恶形式

时间:2012-06-27 10:46:02

标签: ruby-on-rails ruby nested-forms

在我项目的一个模块中,我使用了嵌套表单,在嵌套表单中,我想使用邪恶的表单和邪恶的表单

参考:Ryan bates http://railscasts.com/episodes/346-wizard-forms-with-wicked?view=asciicast

观点>通知> _form.html.erb

<%= form_for(@notice) do |f|%> 
  #notice attributes
<%= f.submit, "Next">
<% end %>

我创建了一个notice_step控制器,并在该控制器中编写了

class NoticeStepsController < ApplicationController
   include Wicked::Wizard
  steps :agendaa
   def show
     @notice = Notice.new
     render_wizard
  end
end

并在通知控制器中创建动作

  def create
    @notice = Notice.new(params[:notice])
      if @notice.save 
      session[:notice_id] = @notice.id 
      redirect_to notice_steps_path 
      else 
        render :new 
    end   
   end 

notice_step&gt; agenda.html.erb

<%= form_for(@notice, url: wizard_path) do |f| %> 
 < div class="field">
    <%= f.fields_for :agendas do |builder| %>
    <%= render "notices/agenda_fields", :f => builder %>
    <% end %>
   <%= link_to_add_fields "Add agenda", f, :agendas %>
 < /div>
 <% end %>

嵌套模型正在运行.....但点击下一步按钮会显示以下错误

It is giving me SyntaxError in User_steps#show compile error
/home/kipl/Desktop/cus_notice/app/views/user_steps/agendaa.html.erb:1: syntax error, unexpected ':', expecting ')'
...ppend=  form_for(@notice, url: wizard_path) do |f| @output_b...
                              ^
/home/kipl/Desktop/cus_notice/app/views/user_steps/agendaa.html.erb:10: syntax error, unexpected kENSURE, expecting $end



任何建议???

1 个答案:

答案 0 :(得分:0)

哈希(:)的冒号表示法仅适用于Ruby 1.9 你应该使用火箭记谱法(=>)。