Ruby On Rails and Storing Data on the Server Side

Hi,

We are going to use dhtmlxGantt in our Ruby On Rails application. As I understand it is easy to load data. All you need is a JSON like:

var tasks = {
data:[
{id:1, text:“Project #1”, start_date:“01-04-2013”, duration:18},
{id:2, text:“Task #1”, start_date:“02-04-2013”, duration:8, parent:1},
{id:3, text:“Task #2”, start_date:“11-04-2013”, duration:8, parent:1}
]
};

This is easy to handle in Rails by something like ‘render json: tasks, status: 200’ in controller.

How can I store data in Ruby On Rails application? Is there any callback where I can put my POST/PUT/PATCH request? What is the best practice?

Best Regards, Szymon

a) you can use gantt’s event
docs.dhtmlx.com/gantt/search.php?query=event

for example from onTaskCreate event you can issue POST request to necessary URL
docs.dhtmlx.com/gantt/api__gantt … event.html

b) you can use dataprocessor, there is no tutorial for gantt+rails, but you can check grid+rails tutorial. While names of fields will differ the logic of server side code will be similar.

dhtmlx.com/blog/dhtmlxgrid-w … -on-rails/

Option B looks more like Ruby way. I will try it and get back to you.

Hi Stanislav,

First of all thank you for your help. I wouldn’t figure it out without you.

It works :laughing: ! Here is my code:
github.com/szymon33/dhtmlxgantt

  1. Follow your article about Grid, option B, with dataProcessor I wrote an admin_controller here:
    github.com/szymon33/dhtmlxgantt … troller.rb
    And sparated Giannt’s view is here:
    github.com/szymon33/dhtmlxgantt … x.html.erb
    Is this all right? Is there on forum an example of db_action method?

  2. If you look at the code then you can easy discover that I have tried to implement task sort order on the list. I can reorder tasks by mouse but I can’t store order position in the database. How to fix it?

  3. I use Rails 4.1 here and I have to make execpetion :null_session to avoid authenticate error in application_controller, but still have “Can’t verify CSRF token authenticity” in server’s log. How to fix it?

  4. How to fix “GET 0.0.0.0:3000/assets/sources/dhtmlxgantt.js.map 404 (Not Found)” in Chrome console?

  5. How can I turn on debug mode in Rails? (enable_log(“path”,true):wink:

  6. Is a milestone feature in standard licence?

I am waiting for your response,

Best Regards, Szymon

(4) Map file must be stored in the same folder as js file, not sure about rails assets pipeline. The simplest solution - delete comment line, with reference to the map file, at the end of dhtmlxgantt.js ( this is dev. time reference anyway, it is activated only when you are opening dev. tools )

(5) You can’t this is feature of server side connectors. In case of rails you can put a custom logging directly in the related actions.

(6) pro feature

I will check the (1)-(3) and will replay on Monday.

(4) the problem is that there is no .map file in your .zip file dhtmlx.com/docs/products/dhtmlxG … load.shtml

@Stanislav: which Monday? :wink: