when I want to take another table column in react and give an error then what to do

 before

@homeworks = @homeworks.map{|m| m.as_json.merge(section: m.section.name, standard: m.standard.standard, subject: m.subject) }


after : we user try method

   @testmarks = testmarks.map{|m| m.as_json.merge(testmark: m, subject: m.test.try(:subject)) }



and in the frontend we use this code

<td>{testmark.subject}</td>

we can take this code directly 

Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5