So far I have been able to wrap my brain around RoR fairly well. But this certain scenario, which I do plan to make use of quite a bit, has me a little stumped.
Currently in my application I have a view setup named dashboard.html.erb. This view requires a high level of customization by the user, they will need to have the ability to add and remove “widgets”(partials) as they see fit. These partials are not designed to use data from the dashboard controller.
My first question is, what would be the best practice way to get data into these partials? My initial thought was to use a ajax get request for each partial that is being displayed, however this seems like unnecessary overhead.
My second question is, when using a controller that does not require a specific view, but instead returns json data, what are the best practices for creating this controller action?
For the first question, you should just use Cells, as they are made exactly for this kind of scenario.
For the second question, there is this quite simple tutorial on “Building a Platform API on Rails” that will get you started easily.
The rationale is that you can just send the ActiveRecord object over the wire using it’s to_json method and the respond_to call. It’s quite simple to build this kind of app with Rails.