Bontina Chen
2007-Jan-27 06:43 UTC
Problems with implementation of dynamically updating scores
Hi, I''m implementing a "digg-like" page, that once you digg. The score for each item will dynamically reflect your current action +1 . I am not sure what''s In the controller I have an action responsible for increase of the score.It has a corresponding rjs in view. -------------------------------------------------------------------------------- def arouse @p=Product.find(params[:id]) @list=List.find_favolist(session[:user_id]) @li=LineItem.findaddeditem(@p.id,@list.id) fair=-IARJQAGddPM@public.gmane.org? puts fair if fair puts ''success'' @p.popular_score +=1 @p.save puts "add" @li = LineItem.new @li.product_id =params[:id] @li.list_id =-7ETwYBW1OEA@public.gmane.org @li.likeornot =1 @li.created_at = Time.now puts "line" @li.save redirect_to_index("推文成功") --> never worked, why? else redirect_to_index("一人只有一票唷") --> never worked, why? end end -------------------------------------------------------------------------------- In the view, I have a div displaying the score. <% if product ==@p %> <div id="current_product"> <%= render(:partial => "score", :object => @p) %> <% else %> <div class="score"> <%= product.popular_score %> <% end %> </div> -------------------------------------------------------------------------------- In arouse.rjs page[:current_product].replace_html :partial => ''score'', :object => @p -------------------------------------------------------------------------------- In _score.rhtml <%= @p.popular_score %> -------------------------------------------------------------------------------- These are pretty much the setting. But it just does not update the new score as I call the arouse with form_remote_tag. Is there anything I''m missing here? Any suggestion and ideas are high welcomed. Abon -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---