כיצד לבצע שינויים בצד ה-backend של יישום discourse באמצעות rails

I don’t think you need to modify code for this, but you may need to run a command from your site’s rails console to get the topics to display in the new order on your site’s homepage.

When you select “Categories with Featured Topics” for the desktop category page style site setting, the order that the featured topics are displayed in should be set by the value of each category’s “Topic List Sort By” setting. Unfortunately, if you make a change to a category’s “Topic List Sort By” setting, that change is not immediately shown on the site’s homepage. I am not sure where Discourse is caching the featured topics that are displayed on the home or what action is used by Discourse to trigger breaking the cache.

From testing on my own site, I see that the cache can be broken by running the following from the rails console:

# Assign the category you want to fix the results for to a variable, for example:

c = Category.find(42)

# Then run
CategoryFeaturedTopic.feature_topics_for(c)

After running that, the topics should get displayed on the homepage in the order you selected for the category’s “Topic List Sort By” setting. I don’t think that running that command can cause any issues, but always be careful running commands from the rails console.

I’m sure there is an easier way to do this. Possibly you just need to wait for up to 24 hours for Discourse to break the cache on the old featured topic list. I’m not seeing where in the code the cache is broken. The relevant code seems to be here: discourse/app/models/category_featured_topic.rb at main · discourse/discourse · GitHub.