Accepts_nested_attributes_for issue

Hello,

I am using accepts_nested_attributes_for for saving the records.

let say I have a model

class User < AR::Base

has_many :books
accepts_nested_attributes_for :books

end

class Book < AR::Base
belongs_to :user
end

Now the params value I am getting is

user={:id => 123, books_attributes={:name => “test”}}

and in my books controller

def create
user = @user.update_attributes(params[:user])
@book = ???
end

Every thing is working as expected but my requirement is that the book
which
is saved I need to know the ID.

How do I find the books ID.

*Thanks
Abhis
*

1 Like