# Has one association with nested form not working rails 5

**URL:** <https://metaruby.com/t/has-one-association-with-nested-form-not-working-rails-5/646>\
**Category:** Rails Forum\
**Created:** [August 24, 2016, 4:57pm UTC](https://metaruby.com/t/has-one-association-with-nested-form-not-working-rails-5/646 "2016-08-24T16:57:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveen1336](https://metaruby.com/letter_avatar_proxy/v4/letter/n/59ef9b/32.png) [@naveen1336](https://metaruby.com/u/naveen1336)\
**Post date:** [August 24, 2016, 4:57pm UTC](https://metaruby.com/t/has-one-association-with-nested-form-not-working-rails-5/646/1 "2016-08-24T16:57:29Z")

</div>

i have implemented has one nested form in rails 4.2.7 but same is not working in rails 5

this the the server log

Started POST “/drivers” for 127.0.0.1 at 2016-08-24 22:24:44 +0530  
Processing by DriversController#create as HTML  
Parameters: {“utf8”=\>“✓”, “authenticity\_token”=\>“vFh5v5tzJMYtGtZLHSnSv61KI3zsUMu9tGLF0KI7sH6O3idS2Xzn2WkKgtdVxJCcZuXG4QZNZZIjkT7vGYDTOw==”, “driver”=\>{“name”=\>“adfa”, “license\_attributes”=\>{“number”=\>“df”}}, “commit”=\>“Create Driver”}  
(1.7ms) begin transaction  
(0.1ms) rollback transaction  
Rendering drivers/new.html.erb within layouts/application  
Rendered drivers/new.html.erb within layouts/application (6.6ms)  
Completed 200 OK in 49ms (Views: 34.1ms | ActiveRecord: 1.8ms)

my controller is

class DriversController \< ApplicationController

def index  
@drivers = Driver.all  
end  
def new  
@driver = Driver.new  
@driver.build\_license  
end

def create  
@driver = Driver.new(formparams)  
if @driver.save  
redirect\_to drivers\_url  
else  
render ‘new’  
end  
end

private  
def formparams  
params.require(:driver).permit(:name, license\_attributes: [:number])  
end  
end

my model is  
class Driver \< ApplicationRecord  
has\_one :license  
accepts\_nested\_attributes\_for :license  
end

is there is way to implement this in rails 5

---

<div class="post-metadata">

**Author:** ![kofno](https://metaruby.com/user_avatar/metaruby.com/kofno/32/159_2.png) [@kofno](https://metaruby.com/u/kofno)\
**Post date:** [August 25, 2016, 11:33am UTC](https://metaruby.com/t/has-one-association-with-nested-form-not-working-rails-5/646/2 "2016-08-25T11:33:28Z")

</div>

Please use the preformatted text option when pasting in code. it makes it much easier to read. Just select all your code and press the the `</>` button to format.

It will make your code look like this:

```
class Foo

  def bar
    puts "some code"
  end

end

```

When your code is easier to read, you are more likely to get a response.
