lundi 31 août 2015

Rails "undefined method" error in forms

I'm trying to create a simple form with a checkbox using Rails, however I keep getting the error: undefined method `recursive' for

My views:

<h1>Create A New Program</h1>
<br>
<%= form_for :program, url: programs_path, :html => {:method => "post"} do |f| %>
  <%= f.check_box(:recursive, {:id => "recursive"}, "recursive", "adhoc") %>Recursive
  <br><br>
  <%= f.submit(:Save) %>
<% end %>

My Controller:

class ProgramsController < ApplicationController
  def new
    @program = Program.new
  end

  def index
    @programs = Program.all
  end

  def edit
    @program = Program.find(params[:id])
  end

  def create
    @program = Program.new(program_params)

    if @program.save
      redirect_to programs_path
    else
      render "new"
    end
  end
end

And my model:

class Program < ActiveRecord::Base
end

I'm struggling to figure out to find a clue as the syntax for check_box does look right. Can someone please help me out? Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire