I am having trouble viewing the nested attributes field in my form. I am in the jobs/new
view and I want have a User form that creates a job as well as a user.
I have everything in this answer Rails 4.0 with Devise. Nested attributes Unpermited parameters
I have also checked out this Nested attributes not showing up in simple form
But the latter answer already applies to my code and it is not showing up. My Code:
Job Model
belongs_to :user
User Model
has_many :jobs
accepts_nested_attributes_for :jobs
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
Jobs/new view
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= f.fields_for :jobs do |builder| %>
<%= render "job_detail_fields", :f => builder %>
<% end %>
<%= f.email_field :email, placeholder: "Enter email", class: "full-width form-field" %>
<% end %>
_job_details_fields
<%= f.text_area :job_description, placeholder: "Job description..." %>
The :job_description
text_area is not showing. If I change the nested attributes form to something like f.fields_for :job
, it will then show but on submission of the form I get unpermitted paramater job as an error. I am pretty sure jobs
is correct but I don't know why it is not showing. Any ideas?
Aucun commentaire:
Enregistrer un commentaire