I am having an annoying problem with my form_for method while creating forums. Everytime I try to submit a forum for creation, I receive this error from Rails.param is missing or the value is empty: forum
The problem is in my forums_param method:
def forum_params
params.require(:forum).permit(:id, :name, :position)
end
The forum part does not exist. The code below is my form for the view:
well.span11
.span7
= form_for @forum, url: forums_path, html: { method: :post } do |f|
= render partial: "form", locals: { f: f }
.actions
= submit_tag 'Create', { class: 'btn btn-primary btn-small' }
.clear
And the partial that it renders:
%fieldset
%div{class: 'control-group'}
= label_tag :title, "Title (required)", class: 'control-label required'
%div{class: 'controls'}
= text_field_tag :name, nil, class: 'span8'
- if @forum.errors[:name]
%p{class: 'error'}#{@forum.errors[:name]}
%div{class: 'control-group'}
= label_tag :position, "Position", class: 'control-label'
%div{class: 'controls'}
= text_field_tag :position, nil, size: 5
%div{class: 'control-group'}
= label_tag :description, "Description", class: 'control-label'
%div{class: 'controls'}
= text_area_tag :description, nil, rows: 10, class: 'span10'
Below is the controller code:
def new
@forum = Forum.new
end
def create
@forum = Forum.new(forum_params)
if @forum.save
redirect_to forums_path, flash: { success: t('.success') }
else
redirect_to forums_path, flash: { error: t('.error') }
end
end
I'm not sure what is going on here. I have already implemented the recommendations described under these posts.
What is the problem here? Help would be greatly appreciated.