How do I access the Ruby REPL?

I seem to remember, several years ago, being able to enter the container and bring up a Ruby REPL where I could interactively use Discourse ORM objects etc. I am trying to debug an issue and want to inspect the posts in a topic, but I can no longer find evidence of this REPL with my Google searches!

Is this still possible?

Thanks!

1 Like
cd /var/discourse
./launcher enter app
rails c
3 Likes

Thanks - it doesn’t ring any bells, but it does seem to work! My next question is where is this API documented? I believe this is more or less the same API that plugins use, right? I need to edit a post, for example.

Thanks again!

This is not really an API, but the standard Rails console. It runs Ruby code in a REPL with the Discourse Rails application loaded. So for example you can use the ActiveRecord API:

p = Post.last
puts p.raw
4 Likes

Thanks, I was able to edit a post’s raw content and call p.save to work around our problem. Much appreciated!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.