So I have the same action for all intents and purposes being executed. Yet one work and the other does not.
DB setup
add_column :cards, :score, :integer, :default => 0
add_column :cards, :comments, :integer, :default => 0
=> Card(id: integer, user_id: integer, event: text, created_at: datetime, updated_at: datetime, score: integer, comments: integer)
The vote controller (this one works)
def create
@vote = Vote.where(:card_id => params[:vote][:card_id], :user_id => current_user.id).first
if @vote
@vote.up = params[:vote][:up]
@vote.save
@card = Card.find(params[:vote][:card_id])
if @vote.up == true
@card.score += 2
else
@card.score -= 2
end
@card.save
else
@vote = Vote.new
@vote.card_id = params[:vote][:card_id]
@vote.user = current_user
@vote.up = params[:vote][:up]
@vote.save
@card = Card.find(params[:vote][:card_id])
if @vote.up == true
@card.score += 1
else
@card.score -= 1
end
@card.save
end
redirect_to :back
end
comments controller (does not work) i get "no implicit conversion of Fixnum into Array"
def create
@comment = Comment.new
@comment.message = params[:comment][:message]
@comment.card_id = params[:comment][:card_id]
@comment.user = current_user
@comment.save
@card = Card.find(params[:comment][:card_id])
@card.comments += 1
@card.save
redirect_to :back
end
What am I missing here? Thank you all for your help in advance.
Ian