redux_rails 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c49a8ea0a58f79e7a4f41f8f90889e39c47c3b25
4
- data.tar.gz: 07a27fa4221f637df04524f78c6e84106d3ad3b9
3
+ metadata.gz: 47499912ebfcb4b6458a809851ce58e051413625
4
+ data.tar.gz: b15c4bf9d2b82456e7a0d7a34a49e8533ae748d1
5
5
  SHA512:
6
- metadata.gz: 3c3e5a1627ab759817ffa8ffaebaa669296a00a35679b6922def59c8cc8cc4aa3eb0536f5fe5820fa21504b4f29ebf467bd4ec67ff168fd4fb6c3de5ee3340e6
7
- data.tar.gz: 61d3e933a7d2f81497777144b3b843e53d7cd76b8fbb5d00820a0e283806968811aebad5921b3387de6872935c1bc9ebad6e5d5cf5584cc981a744d3e94fd430
6
+ metadata.gz: 79a79ef291e0c10c954b67273b19632cf43f45282bca22a11b23b6e8e930d80483a69b7326e7d9d99cf7dec6c1ceadfe91d37b2b9d696264c843b0a410ac9af4
7
+ data.tar.gz: 5112f1d49cc2409d7eade0bcc242f72afb533848c861be0fdbc2d3c45ae47cc5a23c89eb40e3947dca2b54701f64b504049d73328d4005f85250f18a49b3a1cc
data/README.md CHANGED
@@ -2,46 +2,49 @@
2
2
 
3
3
  ## Highlights
4
4
  - install, component and container generator
5
+ - creates a new pack tag for each `rails g redux_rails:install #{your_app_name}` command and installs the necessary lines to manifest.json. Allowing you to have several seperate React apps inside of a single rails project.
6
+ - install component and container folders in any folder location from the command line with the necessary import/export/require lines.
5
7
  - react-router-dom
6
8
  - redux-devtools-extension
7
9
 
8
10
  ### Install generator
9
11
  - Installs a new #{your_app_name}.jsx file in app/javascript/packs with additional Redux setup options commented out for modifications.
12
+ ###### *if you leave #{your_app_name} blank. file, component and container names will default to 'app'*
10
13
  - Links it to public/packs/manifest.json
11
14
  #### Created folders/files
12
- * app/javascript/src,
13
- * app/javascript/src/reducer.js, `for your combineReducer`
15
+ * app/javascript/src/#{your_app_name},
16
+ * app/javascript/src/#{your_app_name}/reducer.js, `for your combineReducer`
14
17
 
15
18
  ###### Component folder
16
- * app/javascript/src/components,
17
- * app/javascript/src/components/app,
18
- * app/javascript/src/components/app/app.js,
19
- * app/javascript/src/components/app/app.scss
19
+ * app/javascript/src/#{your_app_name}/components,
20
+ * app/javascript/src/#{your_app_name}/components/app,
21
+ * app/javascript/src/#{your_app_name}/components/app/app.js,
22
+ * app/javascript/src/#{your_app_name}/components/app/app.scss
20
23
 
21
24
  ###### Container folder
22
- * app/javascript/src/containers,
23
- * app/javascript/src/containers/app,
24
- * app/javascript/src/containers/app/app.js,
25
- * app/javascript/src/containers/app/action.js,
26
- * app/javascript/src/containers/app/actionTypes.js,
27
- * app/javascript/src/containers/app/constants.js,
28
- * app/javascript/src/containers/app/appReducer.js
25
+ * app/javascript/src/#{your_app_name}/containers,
26
+ * app/javascript/src/#{your_app_name}/containers/app,
27
+ * app/javascript/src/#{your_app_name}/containers/app/app.js,
28
+ * app/javascript/src/#{your_app_name}/containers/app/action.js,
29
+ * app/javascript/src/#{your_app_name}/containers/app/actionTypes.js,
30
+ * app/javascript/src/#{your_app_name}/containers/app/constants.js,
31
+ * app/javascript/src/#{your_app_name}/containers/app/appReducer.js
29
32
 
30
33
  ### Component generator
31
34
  #### Created folder/files
32
- * app/javascript/src/components/app/#{your_component_name},
33
- * app/javascript/src/components/app/#{your_component_name}/#{your_component_name}.js,
34
- * app/javascript/src/components/app/#{your_component_name}/#{your_component_name}.scss
35
+ * app/javascript/src/#{your_app_name}/components/app/#{your_component_name},
36
+ * app/javascript/src/#{your_app_name}/components/app/#{your_component_name}/#{your_component_name}.js,
37
+ * app/javascript/src/#{your_app_name}/components/app/#{your_component_name}/#{your_component_name}.scss
35
38
 
36
39
  ### Container generator
37
40
  #### Created folder/files
38
- * app/javascript/src/containers/#{your_container_name},
39
- * app/javascript/src/containers/#{your_container_name}/#{your_container_name}.js,
40
- * app/javascript/src/containers/#{your_container_name}/action.js,
41
- * app/javascript/src/containers/#{your_container_name}/actionTypes.js,
42
- * app/javascript/src/containers/#{your_container_name}/constants.js,
43
- * app/javascript/src/containers/#{your_container_name}/#{your_container_name}Reducer.js
44
- - each generated container reducer will be imported into the root reducer at app/javascript/src/reducer.js and included in the combineReducer
41
+ * app/javascript/src/#{your_app_name}/containers/#{your_container_name},
42
+ * app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}.js,
43
+ * app/javascript/src/#{your_app_name}/containers/#{your_container_name}/action.js,
44
+ * app/javascript/src/#{your_app_name}/containers/#{your_container_name}/actionTypes.js,
45
+ * app/javascript/src/#{your_app_name}/containers/#{your_container_name}/constants.js,
46
+ * app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}Reducer.js
47
+ - each generated container reducer will be imported into #{your_app_name} root reducer at app/javascript/src/#{your_app_name}/reducer.js and included in the combineReducer
45
48
 
46
49
  ## Installation
47
50
 
@@ -49,10 +52,14 @@ Create a new Rails project with webpack option
49
52
 
50
53
  $ rails new app_name --webpack=react
51
54
 
55
+ Then navigate into your new project:
56
+
57
+ $ cd app_name
58
+
52
59
  Add this line to your application's Gemfile:
53
60
 
54
61
  ```ruby
55
- gem 'redux-rails'
62
+ gem 'redux_rails'
56
63
  ```
57
64
 
58
65
  And then execute:
@@ -61,39 +68,40 @@ And then execute:
61
68
 
62
69
  Or install it yourself as:
63
70
 
64
- $ gem install redux-rails
71
+ $ gem install redux_rails
65
72
 
66
- Install all of the dependencies:
73
+ To allow javascript_pack_tag to load assets from webpack-dev-server navigate to `config/environments/development.rb` and add:
67
74
 
68
- $ yarn install
75
+ ```
76
+ config.x.webpacker[:dev_server_host] = "http://127.0.0.1:8080"
77
+ ```
69
78
 
70
- At this point, Rails has created a javascript friendly app for you. To render the sample react component rails creates for you follow these steps.
79
+ To create the packs/manifest.json run:
71
80
 
72
- First create a controller:
81
+ $ ./bin/webpack-dev-server --host 127.0.0.1
73
82
 
74
- $ rails generate controller Pages index
83
+ At this point, Rails has created a javascript friendly app for you. To render the sample react component rails creates for you follow these steps. Or to start using the redux_rails gem skip down to Usage.
75
84
 
76
- This creates a Pages controller with an index method in it. A view template at `app/views/pages/index.html.erb`. Navigate to this file and replace the contents with:
85
+ 1. Open a new terminal tab/window. Make sure you are in the correct directory and create a controller and a view:
77
86
 
78
- ```
79
- <%= javascript_pack_tag 'hello_react' %>
80
- ```
87
+ $ rails generate controller Pages index
81
88
 
82
- To allow javascript_pack_tag to load assets from webpack-dev-server navigate to `config/environments/development.rb` and add:
89
+ - This creates a Pages controller with an index method in it. A view template at `app/views/pages/index.html.erb`.
90
+ 2. Navigate to this file and replace the contents with:
83
91
 
84
92
  ```
85
- config.x.webpacker[:dev_server_host] = "http://127.0.0.1:8080"
93
+ <%= javascript_pack_tag 'hello_react' %>
86
94
  ```
87
95
 
88
- Start the Rails server in a terminal window:
96
+ 3. Start the Rails server in a terminal window:
89
97
 
90
98
  $ Rails server
91
99
 
92
- and in a second server window:
100
+ 4. and in a second server window:
93
101
 
94
102
  $ ./bin/webpack-dev-server --host 127.0.0.1
95
103
 
96
- Navigate to http://localhost:3000/pages/index and you should see
104
+ 5. Navigate to http://localhost:3000/pages/index and you should see
97
105
  ```
98
106
  Hello React!
99
107
  ```
@@ -102,61 +110,67 @@ Hello React!
102
110
 
103
111
  ### Install generator
104
112
  Once your rails app is setup with the webpack=react option and the redux-rails gem is installed execute:
105
- ###### *if you leave #{your_app_name} blank file names will default to 'app'*
113
+ ###### *if you leave #{your_app_name} blank file, component and container names will default to 'app'*
106
114
 
107
- $ rails generate redux-rails:install #{your_app_name}
115
+ $ rails generate redux_rails:install #{your_app_name}
108
116
 
109
117
  This will install the following files:
110
118
  ```
111
119
  app/javascript/src,
112
- app/javascript/src/reducer.js, "this is for your combineReducer"
113
-
114
- app/javascript/src/components,
115
- app/javascript/src/components/#{your_app_name},
116
- app/javascript/src/components/#{your_app_name}/#{your_app_name}.js,
117
- app/javascript/src/components/#{your_app_name}/#{your_app_name}.scss
118
-
119
- app/javascript/src/containers,
120
- app/javascript/src/containers/#{your_app_name},
121
- app/javascript/src/containers/#{your_app_name}/#{your_app_name}.js,
122
- app/javascript/src/containers/#{your_app_name}/action.js,
123
- app/javascript/src/containers/#{your_app_name}/actionTypes.js,
124
- app/javascript/src/containers/#{your_app_name}/constants.js,
125
- app/javascript/src/containers/#{your_app_name}/#{your_app_name}Reducer.js
120
+ app/javascript/src/#{your_app_name}/reducer.js, "this is for your combineReducer"
121
+
122
+ app/javascript/src/#{your_app_name}/components,
123
+ app/javascript/src/#{your_app_name}/components/#{your_app_name},
124
+ app/javascript/src/#{your_app_name}/components/#{your_app_name}/#{your_app_name}.js,
125
+ app/javascript/src/#{your_app_name}/components/#{your_app_name}/#{your_app_name}.scss
126
+
127
+ app/javascript/src/#{your_app_name}/containers,
128
+ app/javascript/src/#{your_app_name}/containers/#{your_app_name},
129
+ app/javascript/src/#{your_app_name}/containers/#{your_app_name}/#{your_app_name}.js,
130
+ app/javascript/src/#{your_app_name}/containers/#{your_app_name}/action.js,
131
+ app/javascript/src/#{your_app_name}/containers/#{your_app_name}/actionTypes.js,
132
+ app/javascript/src/#{your_app_name}/containers/#{your_app_name}/constants.js,
133
+ app/javascript/src/#{your_app_name}/containers/#{your_app_name}/#{your_app_name}Reducer.js
126
134
  ```
127
135
 
128
136
  Once the install generator is finished:
129
- - add the following pack_tags to the file you want the react component to be rendered in
137
+ 1. add the following pack_tags to the file you want the react component to be rendered in
130
138
  ```
131
139
  <%= javascript_pack_tag '#{your_app_name}' %>
132
140
  <%= stylesheet_pack_tag '#{your_app_name}' %>
133
141
  ```
134
- Restart your servers or open two new ones with the commands above and navigate to the page in your browser and you should see:
142
+ 2. Restart your servers or open two new ones with the commands above and navigate to the page in your browser and you should see:
135
143
  ```
136
- Welcome you're now using React and Redux with Rails!
144
+ #{your_app_name} component!
145
+ find me in find me in app/javascript/src/#{your_app_name}/components/#{your_app_name}#{your_app_name}.js
137
146
  ```
147
+
138
148
  ### Component generator
149
+ The Component generator takes two arguments (the new Component name and the desired install location)
150
+ ###### *if you leave #{your_app_name} blank file, component and container names will default to 'app'*
139
151
  To create a new component run:
140
152
 
141
- $ rails generate component #{your_component_name}
153
+ $ rails generate component #{your_component_name} #{your_app_name}
142
154
 
143
155
  This will generate a new folder inside of your components folder with the following files:
144
- - `app/javascript/src/components/#{your_component_name}`
145
- - `app/javascript/src/components/#{your_component_name}/#{your_component_name}.js`
146
- - `app/javascript/src/components/#{your_component_name}/#{your_component_name}.scss`
156
+ - `app/javascript/src/#{your_app_name}/components/#{your_component_name}`
157
+ - `app/javascript/src/#{your_app_name}/components/#{your_component_name}/#{your_component_name}.js`
158
+ - `app/javascript/src/#{your_app_name}/components/#{your_component_name}/#{your_component_name}.scss`
147
159
 
148
160
  ### Container generator
161
+ The Container generator takes two arguments (the new Container name and the desired install location)
162
+ ###### *if you leave #{your_app_name} blank file, component and container names will default to 'app'*
149
163
  To create a new container run:
150
164
 
151
- $ rails generate container #{your_container_name}
165
+ $ rails generate container #{your_container_name} #{your_app_name}
152
166
 
153
167
  This will generate a new folder inside of your containers folder with the following files:
154
- - `app/javascript/src/containers/#{your_container_name}`
155
- - `app/javascript/src/containers/#{your_container_name}/#{your_container_name}.js`
156
- - `app/javascript/src/containers/#{your_container_name}/action.js`
157
- - `app/javascript/src/containers/#{your_container_name}/actionTypes.js`
158
- - `app/javascript/src/containers/#{your_container_name}/constants.js`
159
- - `app/javascript/src/containers/#{your_container_name}/#{your_container_name}Reducer.js`
168
+ - `app/javascript/src/#{your_app_name}/containers/#{your_container_name}`
169
+ - `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}.js`
170
+ - `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/action.js`
171
+ - `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/actionTypes.js`
172
+ - `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/constants.js`
173
+ - `app/javascript/src/#{your_app_name}/containers/#{your_container_name}/#{your_container_name}Reducer.js`
160
174
 
161
175
 
162
176
 
@@ -1,28 +1,29 @@
1
1
  class ComponentGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
  argument :name, :type => :string, :default => "app"
4
-
4
+ argument :install_folder_name, :type => :string, :default => "app"
5
+
5
6
  def create_component_directory
6
- empty_directory("app/javascript/src/components/#{name}")
7
+ empty_directory("app/javascript/src/#{install_folder_name}/components/#{name}")
7
8
  end
8
9
 
9
10
  def create_component_index
10
- create_file "app/javascript/src/components/#{name}/#{name}.js",
11
+ create_file "app/javascript/src/#{install_folder_name}/components/#{name}/#{name}.js",
11
12
  "import React from 'react';
12
- import './#{name}.scss';
13
+ import './#{name}.scss';
13
14
 
14
- const #{name} = () => (
15
- <div className='#{name}'>
16
- <h1>#{name} component!</h1>
17
- <p>find me in app/javascript/src/components/#{name}/#{name}.js</p>
18
- </div>
19
- )
15
+ const #{name} = () => (
16
+ <div className='#{name}'>
17
+ <h1>#{name} component!</h1>
18
+ <p>find me in app/javascript/src/#{install_folder_name}/components/#{name}/#{name}.js</p>
19
+ </div>
20
+ )
20
21
 
21
- export default #{name};"
22
- create_file "app/javascript/src/components/#{name}/#{name}.scss", "
23
- .#{name} {
22
+ export default #{name};"
23
+ create_file "app/javascript/src/#{install_folder_name}/components/#{name}/#{name}.scss",
24
+ ".#{name} {
24
25
 
25
- }"
26
+ }"
26
27
  end
27
28
 
28
29
  end
@@ -1,20 +1,20 @@
1
1
  class ContainerGenerator < Rails::Generators::NamedBase
2
2
  source_root File.expand_path('../templates', __FILE__)
3
3
  argument :name, :type => :string, :default => "app"
4
-
4
+ argument :install_folder_name, :type => :string, :default => "app"
5
5
 
6
6
  def create_directory
7
- empty_directory("app/javascript/src/containers/#{name}")
7
+ empty_directory("app/javascript/src/#{install_folder_name}/containers/#{name}")
8
8
  end
9
9
 
10
10
  def create_container_files
11
- create_file "app/javascript/src/containers/#{name}/#{name}.js",
11
+ create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/#{name}.js",
12
12
  "import * as actions from './actions';
13
13
  import * as constants from './constants';
14
14
  import #{name}Reducer from './reducer';
15
15
 
16
16
  export default { actions, constants, #{name}Reducer };"
17
- create_file "app/javascript/src/containers/#{name}/action.js",
17
+ create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/action.js",
18
18
  "// import {} from './constants';
19
19
  //import * as t from './actionTypes';
20
20
 
@@ -22,20 +22,26 @@ export default { actions, constants, #{name}Reducer };"
22
22
  // type: t.SOME_ACTION,
23
23
  // payload: { text }
24
24
  //});"
25
- create_file "app/javascript/src/containers/#{name}/actionTypes.js",
25
+ create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/actionTypes.js",
26
26
  "//export const SOME_ACTION = '#{name}/SOME_ACTION';"
27
- create_file "app/javascript/src/containers/#{name}/constants.js",
27
+ create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/constants.js",
28
28
  "// export const SOME_CONST = 'SOME_CONST';"
29
29
 
30
- create_file "app/javascript/src/containers/#{name}/#{name}Reducer.js",
30
+ create_file "app/javascript/src/#{install_folder_name}/containers/#{name}/#{name}Reducer.js",
31
31
  "const #{name}Reducer = (state = {}, action) => {
32
- switch (action.type) {
33
- default:
32
+ switch (action.type) {
33
+ default:
34
34
  return state;
35
- }
35
+ }
36
36
  };
37
37
 
38
38
  export default #{name}Reducer;"
39
39
  end
40
40
 
41
+ def add_namedReducer_to_reducer
42
+ inject_into_file "app/javascript/src/#{install_folder_name}/reducer.js", "import #{name}Reducer from './containers/#{name}/#{name}.js'\n", :after => "import { combineReducers } from 'redux'\n"
43
+
44
+ inject_into_file "app/javascript/src/#{install_folder_name}/reducer.js", " #{name}Reducer,\n", :after => "const rootReducer = combineReducers({\n"
45
+ end
46
+
41
47
  end
@@ -3,68 +3,73 @@ module ReduxRails
3
3
  source_root File.expand_path('../templates', __FILE__)
4
4
  argument :name, :type => :string, :default => "app"
5
5
 
6
+ def add_packages
7
+ system("yarn add react-redux redux redux-devtools-extension react-router-dom react-router-redux history")
8
+ end
9
+
6
10
  def create_src_directory
7
11
  empty_directory("app/javascript/src")
12
+ empty_directory("app/javascript/src/#{name}")
8
13
  end
9
14
 
10
- def create_reducer_base_files
11
- create_file "app/javascript/src/reducer.js", "
12
- import { combineReducers } from 'redux'
13
- import #{name}Reducer from './containers/#{name}/#{name}Reducer.js'
15
+ def create_reducer_base_file
16
+ create_file "app/javascript/src/#{name}/reducer.js",
17
+ "import { combineReducers } from 'redux'
18
+ import #{name}Reducer from './containers/#{name}/#{name}.js'
14
19
 
15
- const rootReducer = combineReducers({
16
- #{name}Reducer
17
- })
20
+ const rootReducer = combineReducers({
21
+ #{name}Reducer
22
+ })
18
23
 
19
- export default rootReducer"
24
+ export default rootReducer"
20
25
  end
21
26
 
22
27
  def create_component_base_files
23
- empty_directory("app/javascript/src/components")
24
- empty_directory("app/javascript/src/components/#{name}")
25
- create_file "app/javascript/src/components/#{name}/#{name}.js", "
26
- import React from 'react';
27
- import './#{name}.scss';
28
-
29
- const #{name} = () => (
30
- <div className='#{name}'>
31
- <h1>#{name} component!</h1>
32
- <p>find me in app/javascript/src/components/#{name}/#{name}.js</p>
33
- </div>
34
- )
28
+ empty_directory("app/javascript/src/#{name}/components")
29
+ empty_directory("app/javascript/src/#{name}/components/#{name}")
30
+ create_file "app/javascript/src/#{name}/components/#{name}/#{name}.js",
31
+ "import React from 'react';
32
+ import './#{name}.scss';
33
+
34
+ const #{name} = () => (
35
+ <div className='#{name}'>
36
+ <h1>#{name} component!</h1>
37
+ <p>find me in app/javascript/src/#{name}/components/#{name}/#{name}.js</p>
38
+ </div>
39
+ )
35
40
 
36
41
  export default #{name};"
37
- create_file "app/javascript/src/components/#{name}/#{name}.scss", "
38
- .#{name} {
42
+ create_file "app/javascript/src/#{name}/components/#{name}/#{name}.scss",
43
+ ".#{name} {
39
44
 
40
- }"
45
+ }"
41
46
  end
42
47
 
43
48
  def create_container_base_files
44
- empty_directory("app/javascript/src/containers")
45
- empty_directory("app/javascript/src/containers/#{name}")
46
- create_file "app/javascript/src/containers/#{name}/#{name}.js", "
47
- import * as actions from './actions';
49
+ empty_directory("app/javascript/src/#{name}/containers")
50
+ empty_directory("app/javascript/src/#{name}/containers/#{name}")
51
+ create_file "app/javascript/src/#{name}/containers/#{name}/#{name}.js",
52
+ "import * as actions from './actions';
48
53
  import * as constants from './constants';
49
54
  import #{name}Reducer from './reducer';
50
55
 
51
56
  export default { actions, constants, #{name}Reducer };"
52
- create_file "app/javascript/src/containers/#{name}/action.js", "
53
- // import {} from './constants';
57
+ create_file "app/javascript/src/#{name}/containers/#{name}/action.js",
58
+ "// import {} from './constants';
54
59
  //import * as t from './actionTypes';
55
60
 
56
61
  //export const someAction = (text) => ({
57
62
  // type: t.SOME_ACTION,
58
63
  // payload: { text }
59
64
  //});"
60
- create_file "app/javascript/src/containers/#{name}/actionTypes.js", "
61
- //export const SOME_ACTION = '#{name}/SOME_ACTION';"
65
+ create_file "app/javascript/src/#{name}/containers/#{name}/actionTypes.js",
66
+ "//export const SOME_ACTION = '#{name}/SOME_ACTION';"
62
67
 
63
- create_file "app/javascript/src/containers/#{name}/constants.js", "
64
- // export const SOME_CONST = 'SOME_CONST';"
68
+ create_file "app/javascript/src/#{name}/containers/#{name}/constants.js",
69
+ "// export const SOME_CONST = 'SOME_CONST';"
65
70
 
66
- create_file "app/javascript/src/containers/#{name}/#{name}Reducer.js", "
67
- const #{name}Reducer = (state = {}, action) => {
71
+ create_file "app/javascript/src/#{name}/containers/#{name}/#{name}Reducer.js",
72
+ "const #{name}Reducer = (state = {}, action) => {
68
73
  switch (action.type) {
69
74
  default:
70
75
  return state;
@@ -76,7 +81,9 @@ export default #{name}Reducer;"
76
81
 
77
82
  def create_pack
78
83
  create_file "app/javascript/packs/#{name}.jsx",
79
- "import React from 'react'
84
+ "// add <%= javascript_pack_tag '#{name}' %> and <%= stylesheet_pack_tag '#{name}' %> to the html.erb file you would like your React App to be rendered.
85
+
86
+ import React from 'react'
80
87
  import { render } from 'react-dom'
81
88
  import { Provider } from 'react-redux'
82
89
  import { createStore, combineReducers, applyMiddleware } from 'redux'
@@ -86,12 +93,12 @@ import { devToolsEnhancer } from 'redux-devtools-extension'
86
93
 
87
94
  import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
88
95
 
89
- import #{name} from './src/components/#{name}/#{name}'
96
+ import #{name} from '../src/#{name}/components/#{name}/#{name}.js'
90
97
 
91
- import rootReducer from '../src/reducer'
98
+ import rootReducer from '../src/#{name}/reducer'
92
99
 
93
- //this is for devToolsEnhancer otherwise would be 'let store = createStore(todoApp)'
94
- let store = createStore(todoApp, /* preloadedState, */ devToolsEnhancer(
100
+ //this is for devToolsEnhancer otherwise would be 'let store = createStore(rootReducer)'
101
+ let store = createStore(rootReducer, /* preloadedState, */ devToolsEnhancer(
95
102
  // Specify name here, actionsBlacklist, actionsCreators and other options if needed
96
103
  ));
97
104
  console.log(store.getState())
@@ -109,7 +116,7 @@ document.addEventListener('DOMContentLoaded', () => {
109
116
  <Provider store={store}>
110
117
  <Router>
111
118
  <div>
112
- <Route exact path='/' component={#{name}} />
119
+ <Route path=\"/\" component={#{name}} />
113
120
  </div>
114
121
  </Router>
115
122
  </Provider>,
@@ -119,9 +126,9 @@ document.addEventListener('DOMContentLoaded', () => {
119
126
  end
120
127
 
121
128
  def insert_into_manifest
122
- inject_into_file "public/packs/manifest.json", "\"#{name}.js\" : \"http://0.0.0.0:8080/packs/#{name}.js\",\n", :after => "{\n"
129
+ inject_into_file "public/packs/manifest.json", " \"#{name}.js\" : \"http://0.0.0.0:8080/packs/#{name}.js\",\n", :after => "{\n"
123
130
 
124
- inject_into_file "public/packs/manifest.json", "\"#{name}.css\" : \"http://0.0.0.0:8080/packs/#{name}.css\",\n", :after => "\"#{name}.js\" : \"http://0.0.0.0:8080/packs/#{name}.js\",\n"
131
+ inject_into_file "public/packs/manifest.json", " \"#{name}.css\" : \"http://0.0.0.0:8080/packs/#{name}.css\",\n", :after => "\"#{name}.js\" : \"http://0.0.0.0:8080/packs/#{name}.js\",\n"
125
132
  end
126
133
  end
127
134
  end
@@ -1,3 +1,3 @@
1
1
  module ReduxRails
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redux_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Popwell