I currently have a users table and a posts table. My posts table has a field for user_id, however, I am not sure how I would grab the users name field which is in the users table. I was thinking of using the models afterFind() method and then using SQL to select the data, but there has to be a better way than this. Also, on my view action, I am using the read() function to grab a single post. Would the models afterFind() kick in after it runs read()? If not, is there an equivalent such as afterRead()?
I currently have a users table and a posts table. My posts table has
Share
Just make an association of Post belongsTo User, and every regular find/read operation that has a sufficiently high
recursivevalue will automatically fetch the user with each post.