Y
Y
Yunique2018-08-29 15:31:11
Ruby on Rails
Yunique, 2018-08-29 15:31:11

How to pass form field value from React to Ruby?

There is a simple form on the page - written in JS using the React library.
There are several fields in the form (input, checkbox, select...etc).
I need to transfer the value of the shirt_size field (select from 5 possible options) to the Ruby side (using the Ruby on Rails framework)
. On the Ruby side, I need to implement this through a request.
Something similar already exists on the Ruby side.

def ad_size
    @ad_size ||= RubyClass::Foo.get(не понимаю что нужно писать сюда)
  end

Please tell me the syntax of the query itself. Perhaps I did not provide all the necessary information to understand the question.
I would be grateful if you could tell me what I did not take into account in the formulation of the question, and from what we need to move in order to solve it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2018-08-29
@maxfarseer

Usually, what is written in react does not use the ruby ​​template engine. Therefore, in order to submit something from the form, you need to use the REST API, which is also usually written in the process of moving to React.
Solutions:
a) if everything is clear, search, maybe someone has already started making API and figure out which request needs to be pulled.
b) attach more code if there is still a hodgepodge of templates + react (but this is a road to nowhere)
c) theoretically figure out how applications work in which everything is done on the client (routing + templating), and only requests (REST) ​​fly to the server API)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question