shopapp 0.2.4 → 0.2.6
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 +4 -4
- data/README.md +0 -5
- data/lib/shopapp/templates/shopapp_rails_new.rb +79 -2
- data/shopapp.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a79004b05f353393d4787b77d4261599f671c2d722acd395260748d7f4e572a6
|
|
4
|
+
data.tar.gz: 740821d7b2e7ba2aec300ec2ec9ab5b5243032ad2d3bb7477adf85284f1e11c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7901c675fe62f1fb0edc6de6d13d77f3daeffefec6e37d2963ed63ad8650ae8c7c31654bb57e4583d5279df0aedfbea418175ceecfb72d55ab7ea16b77aa5914
|
|
7
|
+
data.tar.gz: a6f8880d72bbab944295f97633b408afc3c5e88fc403141168864b9154cc1be332bca2409ab6a0cf9837d0bc4a96b44890e9bce1cc110589f0fe609f4c1e7177
|
data/README.md
CHANGED
|
@@ -30,11 +30,6 @@ Just do the following:
|
|
|
30
30
|
rails db:migrate
|
|
31
31
|
rails s
|
|
32
32
|
|
|
33
|
-
Rename the base controller for SomethingsController to one of
|
|
34
|
-
ShopApp base controllers, typically UserAuthenticatedController:
|
|
35
|
-
|
|
36
|
-
class ProductsController < UserAuthenticatedController
|
|
37
|
-
|
|
38
33
|
Hit the newly created route: http://localhost:3999/somethings
|
|
39
34
|
|
|
40
35
|
### Shopapps side by side - set development port
|
|
@@ -18,7 +18,7 @@ gem 'puma'
|
|
|
18
18
|
gem 'sass-rails'
|
|
19
19
|
gem 'shopapp'
|
|
20
20
|
gem 'uglifier', '>= 1.3.0'
|
|
21
|
-
gem '
|
|
21
|
+
gem 'mini_racer'
|
|
22
22
|
gem 'jbuilder', '~> 2.5'
|
|
23
23
|
gem 'bootsnap', '>= 1.1.0', require: false
|
|
24
24
|
gem "audited", "~> 4.7"
|
|
@@ -145,6 +145,77 @@ create_file 'config/local.yml', <<~SETTINGS
|
|
|
145
145
|
authlift_url: 'https://accounts.shoplift.fi/'
|
|
146
146
|
SETTINGS
|
|
147
147
|
|
|
148
|
+
create_file 'lib/templates/rails/scaffold_controller/controller.rb.tt', <<~TEMPLATE
|
|
149
|
+
<% if namespaced? -%>
|
|
150
|
+
require_dependency "<%= namespaced_path %>/application_controller"
|
|
151
|
+
|
|
152
|
+
<% end -%>
|
|
153
|
+
<% module_namespacing do -%>
|
|
154
|
+
class <%= controller_class_name %>Controller < UserAuthenticatedController
|
|
155
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
|
156
|
+
|
|
157
|
+
# GET <%= route_url %>
|
|
158
|
+
def index
|
|
159
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# GET <%= route_url %>/1
|
|
163
|
+
def show
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# GET <%= route_url %>/new
|
|
167
|
+
def new
|
|
168
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# GET <%= route_url %>/1/edit
|
|
172
|
+
def edit
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# POST <%= route_url %>
|
|
176
|
+
def create
|
|
177
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "\#{singular_table_name}_params") %>
|
|
178
|
+
|
|
179
|
+
if @<%= orm_instance.save %>
|
|
180
|
+
redirect_to @<%= singular_table_name %>, notice: <%= "'\#{human_name} was successfully created.'" %>
|
|
181
|
+
else
|
|
182
|
+
render :new
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# PATCH/PUT <%= route_url %>/1
|
|
187
|
+
def update
|
|
188
|
+
if @<%= orm_instance.update("\#{singular_table_name}_params") %>
|
|
189
|
+
redirect_to @<%= singular_table_name %>, notice: <%= "'\#{human_name} was successfully updated.'" %>
|
|
190
|
+
else
|
|
191
|
+
render :edit
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# DELETE <%= route_url %>/1
|
|
196
|
+
def destroy
|
|
197
|
+
@<%= orm_instance.destroy %>
|
|
198
|
+
redirect_to <%= index_helper %>_url, notice: <%= "'\#{human_name} was successfully destroyed.'" %>
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
private
|
|
202
|
+
# Use callbacks to share common setup or constraints between actions.
|
|
203
|
+
def set_<%= singular_table_name %>
|
|
204
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Only allow a trusted parameter "white list" through.
|
|
208
|
+
def <%= "\#{singular_table_name}_params" %>
|
|
209
|
+
<%- if attributes_names.empty? -%>
|
|
210
|
+
params.fetch(:<%= singular_table_name %>, {})
|
|
211
|
+
<%- else -%>
|
|
212
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":\#{name}" }.join(', ') %>)
|
|
213
|
+
<%- end -%>
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
<% end -%>
|
|
217
|
+
TEMPLATE
|
|
218
|
+
|
|
148
219
|
git :init
|
|
149
220
|
git add: '.'
|
|
150
221
|
git commit: "-a -m 'shopapp created'"
|
|
@@ -164,4 +235,10 @@ puts " app.update_attributes uid: '#{@app_id}',"
|
|
|
164
235
|
puts " secret: '#{@app_secret}',"
|
|
165
236
|
puts " redirect_uri: 'http://localhost:#{@app_dev_port}/auth/'"
|
|
166
237
|
puts " Company.find_by_code(:zwr).applications << app unless Company.find_by_code(:zwr).applications.include? app"
|
|
167
|
-
|
|
238
|
+
puts
|
|
239
|
+
puts "To see the power of Shopapp, do this (on Mac):"
|
|
240
|
+
puts
|
|
241
|
+
puts " $ cd #{@app_name}"
|
|
242
|
+
puts " $ rails g scaffold dog name:string"
|
|
243
|
+
puts " $ rake db:migrate"
|
|
244
|
+
puts " $ open http://localhost:3999/dogs ; rails s"
|
data/shopapp.gemspec
CHANGED