Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?

tl;dr How should I approach storing code blocks in a react + rail application? If I were to store the code block data in the rails backend, which datatype should I store it as? And if on the frontend, would mdx files be the best solution?

I’m building…


This content originally appeared on DEV Community and was authored by Annie Zheng

tl;dr How should I approach storing code blocks in a react + rail application? If I were to store the code block data in the rails backend, which datatype should I store it as? And if on the frontend, would mdx files be the best solution?

I’m building a programming quiz application where a question has many answers and each answer (only one is correct) has an explanation. The question consists of the question itself and a code block, similar to what’s circled in orange in the following image: wireframe of the app that shows a sample question containing block of code

As I want to practice building Rails+React (Next.js) applications, I thought that the questions would be stored on the backend. However, is that a good idea? If so, I’m wondering about what would be a possible way to store the code snippets given the Rails datatypes?

Alternatively, I was also considering storing all the questions on the frontend. If I choose to do so, would mdx files be the best solution here?

So, to sum up, which of the following solutions would be best here:

  • Storing code block as markdown files in the frontend
  • Storing code block data in the backend
  • Different solution altogether?


This content originally appeared on DEV Community and was authored by Annie Zheng


Print Share Comment Cite Upload Translate Updates
APA

Annie Zheng | Sciencx (2021-06-07T02:25:11+00:00) Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?. Retrieved from https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/

MLA
" » Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?." Annie Zheng | Sciencx - Monday June 7, 2021, https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/
HARVARD
Annie Zheng | Sciencx Monday June 7, 2021 » Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?., viewed ,<https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/>
VANCOUVER
Annie Zheng | Sciencx - » Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/
CHICAGO
" » Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?." Annie Zheng | Sciencx - Accessed . https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/
IEEE
" » Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists?." Annie Zheng | Sciencx [Online]. Available: https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/. [Accessed: ]
rf:citation
» Advice Needed ➡️ Rails+React/Next.js: how to store code blocks so formatting persists? | Annie Zheng | Sciencx | https://www.scien.cx/2021/06/07/advice-needed-%e2%9e%a1%ef%b8%8f-railsreact-next-js-how-to-store-code-blocks-so-formatting-persists/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.