OK, the scenario is: i`m trying to keep 3 nested forms on the same controller. The relation between the user and shop is working smoothly the problem arises between the shop and shop_type.
So, when i try update the shop_type info in shop edit view
Spit out this error: ShopType(#70233617878800) expected, got ActiveSupport::HashWithIndifferentAccess(#70233610891660)
i searched already about this on api docs but but still a mystery for me why the shop_type is passing as a hash.
thanks.
ShopsController
def new
@user = current_user
@shop = @user.build_shop.shop_type
end
def create
@user = current_user
@shop = @user.build_shop(params[:shop])
if @shop.save
flash.now[:success] = "blah"
render :edit
else
render :new
end
end
def edit
@user = current_user
if @shop = current_user.shop
render :edit
else render :new
end
end
def update
@user = current_user
@shop = current_user.shop
if @shop.update_attributes(params[:shop])
flash.now[:success] = "blah"
render :edit
else
render :edit
end
end
end
ShopModel
belongs_to :user
belongs_to :shop_type
Shop_typeModel
has_many :shops
accepts_nested_attributes_for :shops
attr_accessible :shops, :shop_attributes
I find out, still not clear why i have to use :shop_type_id instead of just :shop_type on fields_for.