ruby - Update a String Attribute in Rails -
i trying update string attribute in database.
i tried using update_attribute isn't working. works integer attributes not string attributes.
how solve ?
edit
code example:
@post = post.find(params[:post_id]) @comment = @post.comments.create!(params[:comment]) @comment.update_attribute(:commenter,user.find_by_id(session[:user_id]).name)
first off, there reason save name string in database? go through association name.
@comment.user.name
i suggest add user_id comments table , use:
@comment.user = user.find_by_id(session[:user_id])
or
@comment.update_attribute(:user_id, session[:user_id])
to update commenter.
Comments
Post a Comment