JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Languages on JVM » JRuby  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 Update不了attribute
littlek





發文: 2
積分: 0
於 2008-01-05 13:37 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
#controller

def update
@item = Item.find(params[:id])
if @item.update_attributes(params[:item])
@item.bid_price = params[:start_price]
@item.save
end
end

#view

<p><label for="item_start_price">Start price</label><br/>
<%= text_field 'item', 'start_price' %></p>

我想要將view 的start_price 複製到 bid_price
可是不知道為什麼 @item.bid_price 總是 null, 請問有人知道原因嗎?


littlek edited on 2008-01-05 14:06
reply to postreply to post
作者 Re:Update不了attribute [Re:littlek]
koji

秒速5センチメートル

站長

發文: 8415
積分: 19
於 2008-01-05 16:50 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
用log印看看
if @item.update_attributes(params[:item])
這邊有確實true嗎?
然後有到@item.save嗎?

koji


reply to postreply to post
JCConf Taiwan 2015 開始售票了!!
Facebook上的TWJUG社團,歡迎加入
作者 Re:Update不了attribute [Re:littlek]
s70487s





發文: 10
積分: 0
於 2008-01-06 11:27 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
@item.bid_price = params[:item][:start_price]
這樣呢?


reply to postreply to post
作者 Re:Update不了attribute [Re:littlek]
littlek





發文: 2
積分: 0
於 2008-01-06 16:41 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
謝謝 s70487s, 原來是我搞錯rails get params的方法....

reply to postreply to post
作者 Re:Update不了attribute [Re:littlek]
s70487s





發文: 10
積分: 0
於 2008-01-06 22:52 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
You're welcome.
繼續努力吧!!


reply to postreply to post
» JWorld@TW »  Languages on JVM » JRuby

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8