Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MIS21
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Owen Ilagan
MIS21
Commits
bb4c816c
Commit
bb4c816c
authored
Jun 30, 2016
by
IEUser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Class updated
parent
9cac3ff1
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
178 additions
and
171 deletions
+178
-171
Gemfile.lock
Gemfile.lock
+0
-167
welcome_controller.rb
app/controllers/welcome_controller.rb
+59
-2
car.rb
app/models/car.rb
+3
-0
motorcycle.rb
app/models/motorcycle.rb
+3
-0
addstudent.erb
app/views/welcome/addstudent.erb
+30
-0
editstudent.erb
app/views/welcome/editstudent.erb
+31
-0
index.html.erb
app/views/welcome/index.html.erb
+5
-1
init_db.rb
config/initializers/init_db.rb
+12
-0
routes.rb
config/routes.rb
+6
-0
20160628024441_cars.rb
db/migrate/20160628024441_cars.rb
+16
-0
schema.rb
db/schema.rb
+13
-1
No files found.
Gemfile.lock
deleted
100644 → 0
View file @
9cac3ff1
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.5)
actionview (= 4.2.5)
activesupport (= 4.2.5)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.5)
activesupport (= 4.2.5)
globalid (>= 0.3.0)
activemodel (4.2.5)
activesupport (= 4.2.5)
builder (~> 3.1)
activerecord (4.2.5)
activemodel (= 4.2.5)
activesupport (= 4.2.5)
arel (~> 6.0)
activesupport (4.2.5)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.3)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (9.0.5)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
debug_inspector (0.0.2)
erubis (2.7.0)
execjs (2.7.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
jbuilder (2.5.0)
activesupport (>= 3.0.0, < 5.1)
multi_json (~> 1.2)
jquery-rails (4.1.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.9.0)
multi_json (1.12.1)
mysql2 (0.4.2-x86-mingw32)
nokogiri (1.6.8-x86-mingw32)
mini_portile2 (~> 2.1.0)
pkg-config (~> 1.1.7)
pkg-config (1.1.7)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.5)
actionmailer (= 4.2.5)
actionpack (= 4.2.5)
actionview (= 4.2.5)
activejob (= 4.2.5)
activemodel (= 4.2.5)
activerecord (= 4.2.5)
activesupport (= 4.2.5)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.5)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.5)
actionpack (= 4.2.5)
activesupport (= 4.2.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (11.2.2)
rdoc (4.2.2)
json (~> 1.4)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.7.1)
sprockets (3.6.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.0.4)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (2.0.5)
turbolinks (2.5.3)
coffee-rails
tzinfo (1.2.2)
thread_safe (~> 0.1)
tzinfo-data (1.2016.5)
tzinfo (>= 1.0.0)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
will_paginate (3.1.0)
PLATFORMS
x86-mingw32
DEPENDENCIES
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
mysql2
rails (= 4.2.5)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
turbolinks
tzinfo-data
uglifier (>= 1.3.0)
web-console (~> 2.0)
will_paginate
BUNDLED WITH
1.10.4
app/controllers/welcome_controller.rb
View file @
bb4c816c
...
...
@@ -5,6 +5,7 @@ class WelcomeController < ApplicationController
def
index
#@students = getStudents()
#getStudents.each do |student|
# newstudent = Student.new
# newstudent.student_id = student[0]
...
...
@@ -13,8 +14,8 @@ class WelcomeController < ApplicationController
# newstudent.save
#end
#@students = Student.all
@students
=
Student
.
where
(
'year_course = ?'
,
'4 BS COMTECH'
)
#
@students = Student.all.paginate(:page => params[:page], :per_page => 8)
#
@students = Student.where('year_course = ?', '4 BS COMTECH')
@students
=
Student
.
all
.
paginate
(
:page
=>
params
[
:page
],
:per_page
=>
8
)
end
...
...
@@ -84,6 +85,62 @@ class WelcomeController < ApplicationController
render
'quiz'
end
def
addstudent
end
def
addstudent_post
student_id
=
params
[
:inputStudentID
]
name
=
params
[
:inputName
]
year_course
=
params
[
:inputYearCourse
]
if
!
student_id
.
empty?
&&
!
name
.
empty?
&&
!
year_course
.
empty?
newstudent
=
Student
.
new
newstudent
.
student_id
=
student_id
newstudent
.
name
=
name
newstudent
.
year_course
=
year_course
newstudent
.
save
redirect_to
'/'
else
@error
=
'yes'
render
'addstudent'
end
end
def
editstudent
id
=
params
[
:id
]
if
!
id
.
nil?
@student
=
Student
.
find
(
id
)
end
end
def
editstudent_post
id
=
params
[
:student_id
]
student_id
=
params
[
:inputStudentID
]
name
=
params
[
:inputName
]
year_course
=
params
[
:inputYearCourse
]
@student
=
Student
.
find
(
id
.
to_i
)
if
!
student_id
.
empty?
&&
!
name
.
empty?
&&
!
year_course
.
empty?
@student
.
student_id
=
student_id
@student
.
name
=
name
@student
.
year_course
=
year_course
@student
.
save
redirect_to
'/'
else
@error
=
'yes'
render
'editstudent'
end
end
def
deletestudent
id
=
params
[
:id
]
@student
=
Student
.
find
(
id
.
to_i
)
@student
.
destroy
redirect_to
'/'
end
private
def
getStudents
return
[
...
...
app/models/car.rb
0 → 100644
View file @
bb4c816c
class
Car
<
ActiveRecord
::
Base
end
\ No newline at end of file
app/models/motorcycle.rb
0 → 100644
View file @
bb4c816c
class
Motorcycle
<
ActiveRecord
::
Base
end
\ No newline at end of file
app/views/welcome/addstudent.erb
0 → 100644
View file @
bb4c816c
<div
class=
"container"
>
<div
class=
"page-header"
>
<h1>
Add Student
</h1>
</div>
<%
if
!
@error
.
nil?
%>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"alert alert-danger"
role=
"alert"
>
<strong>
Please enter required data
</strong>
</div>
</div>
</div>
<%
end
%>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<%=
form_tag
(
"/addstudent"
,
method:
"post"
,
class:
'form-signin'
)
do
%>
<h2
class=
"form-signin-heading"
>
Please enter student data
</h2>
<label
for=
"inputEmail"
class=
"sr-only"
>
Student ID
</label>
<input
type=
"text"
name=
"inputStudentID"
id=
"inputStudentID"
class=
"form-control"
placeholder=
"Student ID"
maxlength=
"20"
>
<label
for=
"inputPassword"
class=
"sr-only"
>
Student Name
</label>
<input
type=
"text"
name=
"inputName"
id=
"inputName"
class=
"form-control"
placeholder=
"Student Name"
maxlength=
"255"
>
<label
for=
"inputPassword"
class=
"sr-only"
>
Year Course
</label>
<input
type=
"text"
name=
"inputYearCourse"
id=
"inputYearCourse"
class=
"form-control"
placeholder=
"Year Course"
maxlength=
"50"
>
<input
class=
"btn btn-lg btn-primary btn-block"
type=
"submit"
value=
"Submit"
></input>
<%
end
%>
</div>
</div>
</div>
app/views/welcome/editstudent.erb
0 → 100644
View file @
bb4c816c
<div
class=
"container"
>
<div
class=
"page-header"
>
<h1>
Edit Student
</h1>
</div>
<%
if
!
@error
.
nil?
%>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"alert alert-danger"
role=
"alert"
>
<strong>
Please enter required data
</strong>
</div>
</div>
</div>
<%
end
%>
<div
class=
"row"
>
<div
class=
"col-md-4"
>
<%=
form_tag
(
"/editstudent"
,
method:
"post"
,
class:
'form-signin'
)
do
%>
<h2
class=
"form-signin-heading"
>
Please enter student data
</h2>
<%=
hidden_field
(
nil
,
:student_id
,
:value
=>
@student
.
id
)
%>
<label
for=
"inputEmail"
class=
"sr-only"
>
Student ID
</label>
<input
type=
"text"
name=
"inputStudentID"
id=
"inputStudentID"
class=
"form-control"
placeholder=
"Student ID"
maxlength=
"20"
value=
"
<%=
@student
.
student_id
%>
"
>
<label
for=
"inputPassword"
class=
"sr-only"
>
Student Name
</label>
<input
type=
"text"
name=
"inputName"
id=
"inputName"
class=
"form-control"
placeholder=
"Student Name"
maxlength=
"255"
value=
"
<%=
@student
.
name
%>
"
>
<label
for=
"inputPassword"
class=
"sr-only"
>
Year Course
</label>
<input
type=
"text"
name=
"inputYearCourse"
id=
"inputYearCourse"
class=
"form-control"
placeholder=
"Year Course"
maxlength=
"50"
value=
"
<%=
@student
.
year_course
%>
"
>
<input
class=
"btn btn-lg btn-primary btn-block"
type=
"submit"
value=
"Submit"
></input>
<%
end
%>
</div>
</div>
</div>
app/views/welcome/index.html.erb
View file @
bb4c816c
...
...
@@ -10,6 +10,8 @@
<th>
ID No
</th>
<th>
Name
</th>
<th>
Year/Course
</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
...
...
@@ -18,11 +20,13 @@
<td>
<%=
item
.
student_id
%>
</td>
<td>
<%=
item
.
name
%>
</td>
<td>
<%=
item
.
year_course
%>
</td>
<td>
<%=
link_to
(
'Edit'
,
'editstudent/'
+
item
.
id
.
to_s
)
%>
</td>
<td>
<%=
link_to
(
'Delete'
,
'deletestudent/'
+
item
.
id
.
to_s
)
%>
</td>
</tr>
<%
end
%>
</tbody>
</table>
<
!--%= will_paginate @students %--
>
<
%=
will_paginate
@students
%
>
</div>
</div>
</div>
config/initializers/init_db.rb
0 → 100644
View file @
bb4c816c
class
InitDB
users
=
Student
.
all
.
size
if
users
==
0
newuser
=
Student
.
new
newuser
.
student_id
=
'123'
newuser
.
name
=
'User'
newuser
.
year_course
=
'Password'
newuser
.
save
end
end
\ No newline at end of file
config/routes.rb
View file @
bb4c816c
...
...
@@ -13,6 +13,12 @@ Rails.application.routes.draw do
get
'quiz'
=>
'welcome#quiz'
post
'quiz'
=>
'welcome#quiz_answer'
get
'addstudent'
=>
'welcome#addstudent'
post
'addstudent'
=>
'welcome#addstudent_post'
get
'editstudent/:id'
=>
'welcome#editstudent'
post
'editstudent'
=>
'welcome#editstudent_post'
get
'deletestudent/:id'
=>
'welcome#deletestudent'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
...
...
db/migrate/20160628024441_cars.rb
0 → 100644
View file @
bb4c816c
class
Cars
<
ActiveRecord
::
Migration
def
change
create_table
:cars
do
|
t
|
t
.
string
:make
,
limit:
20
t
.
string
:engine_displacement
,
limit:
255
t
.
string
:transmission
,
limit:
50
end
create_table
:motorcycles
do
|
t
|
t
.
string
:make
,
limit:
20
t
.
string
:engine_displacement
,
limit:
255
t
.
string
:transmission
,
limit:
50
end
end
end
db/schema.rb
View file @
bb4c816c
...
...
@@ -11,7 +11,19 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
20160627092117
)
do
ActiveRecord
::
Schema
.
define
(
version:
20160628024441
)
do
create_table
"cars"
,
force: :cascade
do
|
t
|
t
.
string
"make"
,
limit:
20
t
.
string
"engine_displacement"
,
limit:
255
t
.
string
"transmission"
,
limit:
50
end
create_table
"motorcycles"
,
force: :cascade
do
|
t
|
t
.
string
"make"
,
limit:
20
t
.
string
"engine_displacement"
,
limit:
255
t
.
string
"transmission"
,
limit:
50
end
create_table
"students"
,
force: :cascade
do
|
t
|
t
.
string
"student_id"
,
limit:
20
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment