M
M
minixomehe2015-08-12 18:20:26
Ruby on Rails
minixomehe, 2015-08-12 18:20:26

Rails helpers in React.js?

Here I did everything using slim (nice and understandable)

- @test.each do |res|
  = link_to root_url(subdomain: res.url) do
    .images style="background-image: url(#{res.image_url(:images).to_s})"
    - if params[:page].blank?
      h1 = res.title

Then I decided to try React.js with its JSX
var Test = React.createClass({
  render: function() {
    var imgUrl = 'http://example.com' + this.props.data.id + '/' + this.props.data.image; // Нифига нельзя работать под дев
    var divImg = {
      backgroundImage: 'url(' + imgUrl + ')'
    };
    return (
      <a href="???">
        <div className="images" background-image={divImg}>
        </div>
        if ???
        <h1>
          {this.props.data.title}
        </h1>
      </a>
      );
  }
});

I still can't figure out how to use rails helpers like root_url(subdomain: res.url), carrierwave helpers. Could of course look bad, but I did not find a solution.
How do you get along with him?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Markov, 2015-08-12
@minixomehe

You need to send ready-made urls from rails to react. Including for different versions of files from carrierwave. And you can also write the address without a domain, then the current domain will be used

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question