Basically a user joins a challenge. Each challenge has a goal like 300000 steps in 30 days. I want keep a track on the user of his daily activities for the next 30 days.
Is this the best design and also is this the right show method in the challenges controller ?
The show method is called when the current_user clicks on a particular challenge.
def show @challenge = Challenge.find(params[:id]) @user_activity = UserActivity.find_by(user:current_user,challenge:@challenge) end User has_many :user_activities has_many :challenges, through: :user_activities class Challenge < ActiveRecord::Base has_many :user_activities has_many :user, through: :user_activities class UserActivity < ActiveRecord::Base belongs_to :challenge belongs_to :user