M
M
Max2016-04-02 20:20:23
Ruby on Rails
Max, 2016-04-02 20:20:23

How to send js variable to rails controller?

Hello, I need to send a JS variable to a rails controller.
ajax code

$.ajax({
                url: "/film_sessions/:id",
                type: "post",
                data: { data_value: JSON.stringify($arr) }
            });

rails code
@test_test = params[:data_value]
But I get an error in the browser console "POST localhost:3000/film_sessions/:id 404 (Not Found)". As far as I understand, I did not specify the route correctly. Please tell me how to fix.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey R, 2016-04-02
@maxprof

Perhaps the problem is that you are sending a POST request, but in the routes GET

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question