Difficulties understanding store interactions between client and server

AI-generated summary

Dimitrie_David is seeking help understanding how store interactions between the client and server work in Discourse, particularly in the context of a custom plugin. They are confused about how Ember.js store calls Rails routes, especially since they don’t see direct AJAX calls in the Notebook plugin despite the use of RestModel. They note that server routes are defined in plugin.rb but don’t see the expected JSON endpoints being called. pfaffman suggests focusing on practical implementation, such as using add_to_serializer, and recommends studying Ember and Rails separately to better understand the integration. Dimitrie_David clarifies that their main goal is to understand the underlying mechanism of how Ember’s store communicates with Rails endpoints.

Hello,

So I am trying to develop a custom plugin for my community. I have followed the tutorials for developing a plugin by @eviltrout and the tutorials still miss important information about communicating between the frontend and backend. I read that everything is ajax calls, but I have found a plugin example that I cannot understand.

I am looking at this Notebook plugin.
So I understand the server routes and the client controller. What I cannot understand is how are the server routes called, even if there are no ajax calls.

I think it has something to do with the RestModel that the note model extends.
Still I cannot find the implementantion that specifies what routes you have to define in the server so that the store in ember can use.

I would greatly appreciate any help!

Also, the server routes are defined in plugin.rb and reading from this post, I expected to see some calls to {route}.json from ember, but nothing.

I guess there is a wrapper somewhere in the discourse services, but I cannot find it.

Do you need to add data to a new rails model, or are you adding stuff to existing ones? You can, for example, add_to_serializer.

It might help to share more details about what you’re trying to accomplish.

First of all, I want to understand how the mechanism works. And I am referring to how does the store in ember.js call endpoints in rails.

Rails puts stuff in json that gets loaded by ember.

For me it’s easier to try to accomplish something and understand what’s required to accomplish that rather than understand the whole first.

You can read books on ember and rails if you want to understand it all.

I read a book on rails, which gave me some understanding of that. The ember side had taken me a long while to make any sense at all of ember.