I'm using Ruby 2.4 and rails 5.1.7
I want to assign variable value with conditional if plan x = plan x OR plan is null.
For example, my original table will return these results:
plan term hours
A 4 60
(nul) 2 60
(nul) 3 60
B 5 60
A 6 60
And I need result to be like this:
plan term hours
A 2 60
A 3 60
A 6 60
B 2 60
B 3 60
B 5 60
Can I use something like plan || plan.blank? for this?
courses.each do |course|
if course.code.any?
curriculum = course.code.find_by(code: code)
next if code.blank?
term = terms.find_by(order: term.to_i)
plan = Plan.find_by(course: course, title: plan_title)
Hour.find_or_create_by(
term: term,
hours: hours,
plan: plan || plan.blank?