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

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -