0

I have a field which is not in my model, but it is in my _form.html.erb . Now i want to get it from form, but i get this error :

undefined method 'description' for Object

My controller:

def job_params
@job_params ||=params.permit(:description) # (description is not an attribute in job model ).

How can i get description ?? My form:

<%= form_for(@job) do |f| %>
<div class="field">
  <%= f.label :description %><br>
  <%= f.text_field :description %>
</div>
oj5th
  • 1,379
  • 10
  • 25
voxter
  • 853
  • 2
  • 14
  • 30

1 Answers1

1

use attr_accessor in your model for description.

class DummyModel < ActiveRecord::Base
  attr_accessor: description
end

Reference

You might also look at this one.

Community
  • 1
  • 1
Emu
  • 5,763
  • 3
  • 31
  • 51