I am trying to use Object.find(params[]) to only return objects with :stage_id = integer
Here is my controller code
def show
@lesson = Lesson.find(params[:id])
@stage1 = @lesson.units(params[:stage_id] == 1)
@stage2 = @lesson.units(params[:stage_id] == 2)
Each lesson has many units, each unit has either a stage_id = 1 or stage_id = 2, I want @stage1 to become an array with units that only have a stage_id value of 1. The same goes for stage2.
How can I properly use params to return only units that have the indicated table values?
1 Answer