GithubHelp home page GithubHelp logo

Comments (24)

alexkuang avatar alexkuang commented on September 1, 2024 1

I think it might be related to this issue: #11

Try setting config.react.variant = :development in config/environments/development.rb (and the corresponding in production, etc) and see if that helps.

from react-rails.

adtaylor avatar adtaylor commented on September 1, 2024

+1

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

I will take a look at it when I'm back from skiing next week

from react-rails.

steadicat avatar steadicat commented on September 1, 2024

I run into this issue when precompiling assets for production. Yes, I have config.react.variant = :production in my production.rb.

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

OK, so... I'm gonna tackle this on Monday.
In the meantime could you try this branch https://github.com/jakubmal/react-rails/tree/feature/react-dropin ? Just to prove it's not shady it's here as PR, awaiting some minor formal fixes.

You are including it inside a rails engine, would you mind if I asked for a little gist? @kjf @adtaylor @steadicat

from react-rails.

steadicat avatar steadicat commented on September 1, 2024

Oops, I missed the "inside rails engine" part. I'm using react-rails the normal way (react-rails in the the gemfile and line config.react.variant = :production in production.rb). Your branch did not fix it for me.

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

@steadicat is your last message

Your branch did not fix it for me.

about usage inside rails engine, or not?

from react-rails.

zpao avatar zpao commented on September 1, 2024

@steadicat any more details? Rails version, ruby version, etc.

I'm not familiar with Rails engines... Can somebody having issues describe the minimum needed to repro?

from react-rails.

steadicat avatar steadicat commented on September 1, 2024

@zpao: Ruby 1.9.3, Rails 3.2.14.

@JakubMal: I'm not using an engine.

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

@kjf you still there?

from react-rails.

kjf avatar kjf commented on September 1, 2024

@JakubMal Sorry, totally forgot about this issue. I'll throw up an example app later today that should highlight the issue.

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

@kjf just making sure, you haven't forgotten...
@adtaylor maybe you could spare a moment for a repro case

from react-rails.

kjf avatar kjf commented on September 1, 2024

@JakubMal Apologies! Have been swamped.

This should highlight the issue: https://github.com/kjf/React-Rails-Engine

If you start your rails server and visit: http://localhost:3000/blorgh then you should see the exception Sprockets::FileNotFound thrown with the message "couldn't find file 'react'"

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

Hi, no problem.
It is a combination of:

  1. Rails Engine architecture
  2. #11

I'm going to describe the steps I took to make this work, and if it's not enough for you, I could send you a working application.

Let's start with Rails Engine. Take a look at: http://stackoverflow.com/a/5850503/362830
Essentially, you need to load dependencies of your engine yourself.

Then comes the very unfortunate #11, react will not be added to assets, unless config.react.variant is set. You will have to add an initializer, which will run before react_rails.setup_engine. I could slightly help you here, and create a fork for you, variant would come from Rails.env unless otherwise defined.

As to when this fix could be in a main branch, not soon, but there are certain changes coming... I will let you know.

from react-rails.

kjf avatar kjf commented on September 1, 2024

@JakubMal Gotcha, had tried loading dependencies so it was #11 was tripping me up. Adding initialiser should do the job. Thanks for your help on this!

from react-rails.

steadicat avatar steadicat commented on September 1, 2024

I'm still having trouble with this, but I'm not using a Rails engine. I get couldn't find file 'react' when running rake assets:precompile. Should I file a separate issue?

from react-rails.

jtmalinowski avatar jtmalinowski commented on September 1, 2024

@steadicat separate issue, please 👍
@kjf do you think anything should be changed on react-rails' part? or is should we rather close this?

from react-rails.

kjf avatar kjf commented on September 1, 2024

@JakubMal I think everything is clear now. Close away and thanks again!

from react-rails.

5minpause avatar 5minpause commented on September 1, 2024

Hi @JakubMal.

Sorry for opening this old ticket, but it's my problem exactly!

Regarding your answer:

Then comes the very unfortunate #11, react will not be added to assets, unless config.react.variant is set. You will have to add an initializer, which will run before react_rails.setup_engine. I could slightly help you here, and create a fork for you, variant would come from Rails.env unless otherwise defined.

I can't seem to get it to work with my engine setup.

Here's what I did. Inside lib/my_engine/engine.rb

module MyEngine
  class Engine < ::Rails::Engine

    initializer("my_engine.react-rails") do |app|
      MyEngine::Engine.config.react.variant = :production
    end

    require 'react-rails'

# and more

When I load the Rails console and query:

irb(main):003:0> MyEngine::Engine.config.react
=> {:variant=>:production}

But loading it in application.js (app/assets/my_engine/application.js) doesn't work.

couldn't find file 'react'

Any help is appreciated.

from react-rails.

JonCrawford avatar JonCrawford commented on September 1, 2024

@5minpause Did you figure this out?

from react-rails.

5minpause avatar 5minpause commented on September 1, 2024

No @JonCrawford, I didn't. I only found a (bad) workaround.

from react-rails.

brettjurgens avatar brettjurgens commented on September 1, 2024

for what it's worth, adding require react-rails to my engine.rb worked for me

from react-rails.

JonCrawford avatar JonCrawford commented on September 1, 2024

Same here. That did it. 👍
On Tue, Jul 28, 2015 at 11:17 AM Brett Jurgens [email protected]
wrote:

for what it's worth, adding require react-rails to my engine.rb worked
for me


Reply to this email directly or view it on GitHub
#21 (comment).

from react-rails.

neohunter avatar neohunter commented on September 1, 2024

same problem here. solution is not merged into master?

from react-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.