How do I increment “week” property?
def newweek
current_user.userprofile.week += 1
respond_to do |format|
format.html { redirect_to :action => "index"}
end
end
The initial value is 0. Each time newweek is run, the week should be incremented by 1.
Unfortunately, each time newwek is run, the value remains to 1. How do I fix that?
EDIT
class NewWeekToUserprofile < ActiveRecord::Migration
def change
add_column :userprofiles, :week, :integer, :default => 0
end
end
You could use
.incrementmethod.