
Untitled
By: a guest on
Aug 9th, 2012 | syntax:
None | size: 0.78 KB | hits: 6 | expires: Never
Rails 2.3 star rating widget
<%= hidden_field_tag("lot_id", lot.id) %>
<%= f.submit :Submit %>
def create
lot = Lot.find_by_id(params[:lot_id])
@rating = Rating.new(params[:rating])
@rating.lot_id = @lot.id
@rating.user_id = current_user.id
if @rating.save
flash[:notice] = "your rating has been saved"
redirect_to :id => nil
end
end
def update
lot = Lot.find_by_id(params[:lot_id])
@rating = current_user.ratings.find_by_photo_id(@photo.id)
if @rating.update_attributes(params[:rating])
flash[:notice] = "your rating has been saved"
redirect_to :id => nil
end
end
end