Help with habtm models in one form

Hi I have a post and a category model

class Post < ActiveRecord::Base
has_and_belongs_to_many :categories

end
class Category < ActiveRecord::Base
has_and_belongs_to_many :posts

end

I created join table migration files

Now I wanna create category while creating post I mean user can choose category or add a new category to this post how can i imlement this?