nil itu sudah otomatis -_-

Posted: January 5, 2007 in Ruby on Rails

pernah liat ini?

def edit
@article_category = ArticleCategory.find(params[:id])
@article_categories = ArticleCategory.find(:all)
return unless request.post?
@article_category = ArticleCategory.find(params[:id])
# @article_category = params[:article_category]
# @article_category.parent_id = nil if params[:article_category][:parent_id] == ”
if @article_category.update_attributes(params[:article_category]) # save # update_attributes(params[:article_category])
redirect_to :action => “list”
flash[:notice] = “Successfully updated…”
end
end
itu sudah gw comment yang ngaco nya! BTW itu controller, modelnya pakai database struktur pohon. Jadi jangan terkecoh dengan kelas string yg size nya kosong di parent_id nya ya. Pas di save nil itu sudah otomatis…

tinggalkan feedback konstruktif atau lebih baik diam

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s