-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitignore
216 lines (144 loc) · 6.67 KB
/
.gitignore
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
Note on the project / todo.
Whole app Car inventory
--- √ phase1
set up user with Devise functionality
This include runing all the needed command
set up admin on user which will be a boolean
https://github.com/heartcombo/devise/wiki/How-To:-Add-an-Admin-Role
option 2: on the link.
To identify Admin you put any where
if current_user.admin?
# do something
end
If the page could potentially not have a current_user set then:
if current_user.try(:admin?)
# do something
end
use code to grant Admin access to current user
current_user.update_attribute :admin, true
---- phase 2
Demo app | my app
√ users - user
√ project(name, description:text, references to users) - dealership(name,address, references to user)
√ task(name,description:text status project:references) - inventory => inventory of cars(carmodel,price:integer, status [old or new], dealership:references)
√Set up the inventory for cars. models,controller, views
√Set up dealership models,controller, views
√ Set up dealership models,controller, views
√Test that we are able to sign up.
Demo sign-up account - admin
Emails : [email protected]
password: bob123!freshly
Emails : [email protected]
password: asfasf!123
------√ phase 3 Give admin the power to add, edit and destory inventory
For admin, Include the instruction on how to do it in the terminal
drop into irb
and Change user boolean to admin.
add if
<%if current_user && current_user.admin? %>
//do something
<%end%>
To change user to Admin in Terminal
Cd into you car_inventory file
use the app by:
Sign-up or log_ing into a user account.
In the car_inventory terminal
run "rails c"
then run "User.first" to make sure you are on the right user.
It shows
#<User id: 1, email: "[email protected]",
created_at: "2021-02-12 18:39:27.791451000 +0000", updated_at: "2021-02-12 18:39:27.791451000 +0000", admin: false>
use code to grant Admin access to current user
run "@user = @user.admin = true "
run "@user.admin = true"
run "@user.save"
current_user.update_attribute :admin, true
user and admin video. min 6:40
-----------------------------------------------------phase 4
Stop video at 19:53. have a little issue.
Edit button is giving me issues.
// Put in readme.
To change user to Admin in Terminal
Cd into you car_inventory file
use the app by:
Sign-up or log_ing into a user account.
In the car_inventory terminal
run "rails c"
then run "User.first" to make sure you are on the right user.
It shows
#<User id: 1, email: "[email protected]",
created_at: "2021-02-12 18:39:27.791451000 +0000", updated_at: "2021-02-12 18:39:27.791451000 +0000", admin: false>
use code to grant Admin access to current user
run "@user = @user.admin = true "
run "@user.admin = true"
run "@user.save"
------ or
current_user.update_attribute :admin, true
--------------------------------------------Phasee 5 Install and Rails Rubocup
ultimate sources rubocop https://docs.rubocop.org/rubocop/1.0/cops_style.html#styledocumentation
https://github.com/rubocop-hq/rubocop-rails
https://github.com/rubocop-hq/rubocop
exclude certain files
https://docs.rubocop.org/rubocop/configuration.html#includingexcluding-files
/// need a little configuration.
Readme: When we run "rubocop add --force-exclusion"
It help rubocop omit files saved in .rubocop.yml
Readme: Todo: Add all the comments as needed.
Then, explain how to run rubocop in exclude certain files.
MAke sure to CD into the correct file
-----------------------------------Phase 6 Install rspec--
TDD testing for inventory cars
If we are using rspec on project we build already.
https://semaphoreci.com/community/tutorials/how-to-test-rails-models-with-rspec
ReadMe: Rails comes with it our natural test enviorments
put rspec in the gemfile
run "bundle Install"
run "rails generate rspec:install"
To run rspec
run bundle exec rspec
Generate test files with rspec.
https://relishapp.com/rspec/rspec-rails/docs/generators
rspec contoroller
https://relishapp.com/rspec/rspec-rails/v/4-0/docs/controller-specshttps://relishapp.com/rspec/rspec-rails/v/4-0/docs/controller-specs
--------------√ Price change -%20 at end of every month -
Get the end of the month
https://stackoverflow.com/questions/14120661/get-last-day-of-the-month-in-ruby
Created in the dealership model.
Now we need to use it in out Show page with the prices.
In video Project. See how
percent_complete was used in the Project model and inside the project
minutes: 49:10, or 1:03:05
For my project. end_of_month in dealership model
Get the last of the month === https://www.rubyguides.com/2015/12/ruby-time/
Note: Feb end in 29 days
june 30 days
rest of month has 31 days
method
if date in a month is 29th or 30 or 31?
reduce price by %20
https://www.geeksforgeeks.org/ruby-date-and-time/
Readme:
-------------------------------------Sign-out button... Look at devise files
Move the sign-out button. so be where we can use it all the time.
Look back onto Your rails video
Resources : https://stackoverflow.com/questions/26595874/i-want-make-push-and-get-error-src-refspec-master-does-not-match-any
------------------- Issues with mimemagic---
Manual update in the gemlock file to latest update and run
"bundle install"
"rake db:migrate'
"rails s -- to launch server"
--------- As for the wrong number of argument issue----
fix inside inventory controller was
@inventory.update(inventory_params)
redirect_to(@inventory.dealership,notice: 'Inventory was successfully updated.')
-------- Worked great.-----
---- Finish, Give it a simple background and a Log to the top left of the page.---
CarLoad.... Title.
Car Logo-- https://cdn5.vectorstock.com/i/1000x1000/68/44/car-logo-with-circle-hand-colorful-logo-vector-22266844.jpg
backgroun-- gif -- https://media0.giphy.com/media/10cXff6xep02Na/giphy.gif
Great alternative== https://media.istockphoto.com/videos/the-sport-car-is-covered-with-a-white-cloth-on-a-black-background-the-video-id1176536301
Use resources to answer this qusestion :
https://medium.com/swlh/add-a-background-video-to-your-landing-page-in-rails-5-7b9c459023bc
# <img src="/assets/logo.png" />
# <%= video_tag "car_video.mp4", autoplay: :autoplay, loop: :loop, muted: :muted, class: "home_video" %>
Css Logo creation. : https://www.w3schools.com/css/css3_images.asp