Get a list of records with filter based on a linked record

Topic Labels: Formulas
1153 1
Showing results for 
Search instead for 
Did you mean: 
4 - Data Explorer
4 - Data Explorer

So I have two tables, Project Reviews and Students. The Project reviews tables has a column that is linked to the student that submitted the review.
Now, I am trying to retrieve records submitted by a particular student and I kept getting an empty array.
Here is what I tried: .all(filter: '{Student} = "#{[student_id]}"')
I am using the Airtable Ruby Gem on a rails app. Any help is appreciated. Thanks.

1 Reply 1
4 - Data Explorer
4 - Data Explorer

Hello @Operations,

If I understand you well, you're attempting to obtain entries from the "Project Reviews" table that were provided by a specific student while using the Airtable Ruby Gem in a Rails app. When you try to filter the records by the student's ID, you receive an empty array.

Based on the code you gave, it appears that you are attempting to incorporate the student ID into the filter expression via string interpolation. However, the syntax is incorrect, which is most likely causing the filter to fail.

Instead, use the following syntax to resolve this issue:

all(filter: '{Student} = "' + student_id + '"')

This will concatenate the student ID variable with the filter expression, producing a valid filter string that should function properly.

Alternatively, you can use string interpolation with the following syntax:

all(filter: "{Student} = '#{student_id}'")

This syntax surrounds the student ID variable with single quotes rather than double quotes, allowing the variable to be properly interpolated into the filter string.

I hope this was helpful!