react.rb
react.rb copied to clipboard
rails generator
We need a rails generator
-
where does it go? can it go in the react.rb gem? that would be great, otherwise I guess we have to make a reactive-rails ??? gem??? (back to name space issues)
-
what does it do... I suggest: a) rails g reactrb:install b) rails g reactrb:component ComponentName
install sets up all the files, etc, and component first makes sure install has been run, then adds a component.
The component template file would contain a complete but blank component with all the call back macros
@catmando
- It belongs in the react.rb gem and is only required if Rails is present.
- Yep.
@ajjahn I think this would be a good opportunity to pull out rails stuff into it's own gem actually. RE: components would we have an option on where to put it, i.e. app/assets/javascripts/components vs. app/views/components, or a user customizable destination
@fkchang I agree that react.rb and the pre-rendering/rails related stuff could be separated. I foresee a collection of gems that work in tandem and can be integrated via a single meta gem or on there own... But I think we need some more refactoring before we're able to cleanly draw those lines.
I'm chipping away at refactoring, but we could always go faster with more tests. (A subtle hint for anyone reading.)
Hi @ajjahn, I discussed with @catmando since we are going to both do some presentation about react.rb at the beginning of febuary. We both would like this issue to be done as to make thing easier to explain how to start with react.rb, so I offer to tackle this issue this week-end if it's OK for you. I think I'll do a separate gem for now, and let you decide if you guys want to integrate it later on.
Would that be OK for you?
@loicboutet Sure, that'd be great!
@ajjahn Great :) I'll start this week-end and will report my progress here then.
Hey guys,
The generator is ready here : https://github.com/loicboutet/reactive-rails-generator And is pushed as a separate gem here : https://rubygems.org/gems/reactive_rails_generator
It can install reactrb and has option to install reactive-record, and reactive-router.
It greatly simply the getting start, which now can consist of :
rails g reactb:install
bundle udpdate
rails g reactrb:component Home::Show
rails g controller Home show
# edit app/controllers/homecontroller.rb to add a render_component inside the show action
# edit the app/react/components/home/show.rb to put something in the render
rails s
I will probably continue to improve the generator. With @catmando we already discussed the possibility to do rails g reactrb:component Home::How --with-controller
so the controller, the associated action with a render_component and the associated route is created.
I'm also personnally leaning toward making a "scaffold" associated with reactive-record to have a simple UI generated like the rails scaffold.
@loicboutet Good work! If you can get some specs testing the generator behavior, I'd be for merging this in.
@ajjahn Thanks :) Sure I can add some specs. Which test library are you using?
Rspec: https://github.com/zetachang/react.rb/blob/master/reactive-ruby.gemspec#L27.
This issue was moved to reactrb/reactrb#90