The nested attributes is not saved in the database on Rails 5
<p>I am having a trouble that I am new with ROR and want to save some images for the organization using nest attributes or for simplicity just a String in order to try the nested attributes saving in the database but actually it is not saved.</p>

<p><strong>Organization Model</strong></p>

<pre><code>class Organization &lt; ApplicationRecord
has_secure_password
has_many :needs, dependent: :destroy
has_many :org_images, dependent: :destroy
has_many :stringas, dependent: :destroy
accepts_nested_attributes_for :org_images, :reject_if =&gt; lambda { |t| t['org_image'].blank? }
accepts_nested_attributes_for :stringas, :reject_if =&gt; lambda { |t| t['stringa'].blank? }
</code></pre>

<p><strong>Schema</strong></p>

<pre><code>create_table "org_images", force: :cascade do |t|
t.string   "caption"
t.integer  "organization_id"
t.datetime "created_at",         null: false
t.datetime "updated_at",         null: false
t.string   "photo_file_name"
t.string   "photo_content_type"
t.integer  "photo_file_size"
t.datetime "photo_updated_at"
end

  create_table "stringas", force: :cascade do |t|
t.string   "name"
t.datetime "created_at",      null: false
t.datetime "updated_at",      null: false
t.integer  "organization_id"
end
</code></pre>

<p><strong>Organization Controller</strong></p>

<pre><code>def new
@organization = Organization.new
3.times {@organization.org_images.build}
@organization.stringas.build # added this
end
  def organization_params
 params.require(:organization).permit(:org_name, :email, :password, :info,:image, :website_URL, :contacts, :logo_url , :password_confirmation  ,stringas_attributes:[:name,:id,:organization_id,:created_at,:updated_at] ,org_images_attributes: [:id,:organization_id,:caption, :photo_file_name, :photo_content_type,:photo_file_size,:photo_updated_at])
</code></pre>

<p>end
<strong>Organization Form</strong></p>

<pre><code>&lt;div class= "field"&gt;
</code></pre>

  

<pre><code>&lt;% if builder.object.new_record? %&gt;

  &lt;p&gt;
  &lt;%= builder.label :caption, "Image Caption" %&gt;
  &lt;%= builder.text_field :caption %&gt;
  &lt;/p&gt;

  &lt;p&gt;
  &lt;%= builder.label :photo, "Image File" %&gt;
  &lt;%= builder.file_field :photo %&gt;
  &lt;/p&gt;

&lt;% end %&gt;
</code></pre>

  
  

<pre><code>&lt;% if builder.object.new_record? %&gt;

  &lt;p&gt;
  &lt;%= builder.label :name %&gt;
  &lt;%= builder.text_field :name%&gt;
  &lt;/p&gt;

&lt;% end %&gt;

&lt;% end %&gt;
</code></pre>

<p>
<strong>Stringa and org_image Models</strong></p>

<pre><code>class OrgImage &lt; ApplicationRecord
belongs_to :organization
has_attached_file :photo, :styles =&gt; { :small =&gt; "150x150&gt;", :large =&gt;      "320x240&gt;" }
validates_attachment_presence :photo
validates_attachment_size :photo, :less_than =&gt; 5.megabytes
end

class Stringa &lt; ApplicationRecord
belongs_to :organization
end
</code></pre>

<p><strong>Organization cotroller create</strong></p>

<pre><code>  def create
@organization = Organization.new(organization_params)

respond_to do |format|
  if @organization.save
    session[:organization_id]=@organization.id
    format.html { redirect_to @organization, notice: 'Organization was successfully created.' }
    format.json { render :show, status: :created, location: @organization }

  else
    format.html { render :new }
    format.json { render json: @organization.errors, status: :unprocessable_entity }
  end
end
</code></pre>

<p>end
<a href="https://github.com/MarwanAlaa94/DonationRepo/tree/marwanMerged" rel="nofollow">git repository</a>
<strong>Thanks for your help</strong></p>