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)
[email protected]?
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 [email protected]
@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