2

I am currently fetching all notes in model by

@notes_list = current_user.notes.order(:title).group_by { |note| note.title[0] }

Later i added a column to notes table that is known a boolean column.

Now i want to fetch only true valued columns and false valued columns separately something like below

@notes_true_list = blah....
@notes_false_list = blah....

Can anyone help me?

1 Answer 1

2

Try the below code.

@notes_true_list = current_user.notes.where(known: true).order(:title).group_by { |note| note.title[0] }

@notes_false_list = current_user.notes.where(known: false).order(:title).group_by { |note| note.title[0] }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.