-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
department, member cotroller methods added
- Loading branch information
Showing
16 changed files
with
201 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,7 @@ | ||
== README | ||
|
||
This README would normally document whatever steps are necessary to get the | ||
application up and running. | ||
Open source Online Ticketing System. | ||
|
||
Things you may want to cover: | ||
== License | ||
|
||
* Ruby version | ||
|
||
* System dependencies | ||
|
||
* Configuration | ||
|
||
* Database creation | ||
|
||
* Database initialization | ||
|
||
* How to run the test suite | ||
|
||
* Services (job queues, cache servers, search engines, etc.) | ||
|
||
* Deployment instructions | ||
|
||
* ... | ||
|
||
|
||
Please feel free to use a different markup language if you do not plan to run | ||
<tt>rake doc:app</tt>. | ||
GNU GENERAL PUBLIC LICENSE V3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
class MembersController < ApplicationController | ||
def index | ||
@members = Member.all | ||
end | ||
|
||
|
||
def new | ||
@member = Member.new | ||
end | ||
|
||
def edit | ||
@member = Member.find(params[:id]) | ||
end | ||
|
||
def create | ||
#render plain: params[:member].inspect | ||
@member = Member.new(member_params) | ||
if @member.save | ||
|
||
flash[:notice] = "Member was successfully created." | ||
redirect_to member_path(@member) | ||
else | ||
render :new | ||
end | ||
end | ||
|
||
def show | ||
@member = Member.find(params[:id]) | ||
end | ||
|
||
def destroy | ||
@member = Member.find(params[:id]) | ||
@member.destroy | ||
flash[:notice] = "Member was successfully deleted." | ||
redirect_to members_path | ||
end | ||
|
||
def update | ||
@member = Member.find(params[:id]) | ||
if @member.update(member_params) | ||
flash[:notice] = "Member was successfully updated." | ||
redirect_to member_path(@member) | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
|
||
private | ||
def member_params | ||
params.require(:member).permit(:email,:password) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class Department < ActiveRecord::Base | ||
validates :title, presence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% if @department.errors.any? %> | ||
<ul> | ||
<% @department.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<%= form_for @department do |f| %> | ||
<p> | ||
<%= f.label :title %><br/> | ||
<%= f.text_field :title %> | ||
</p> | ||
<p> | ||
<%= f.submit %> | ||
</p> | ||
<% end %> | ||
<%=link_to "Back to department list", departments_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Edit department </h1> | ||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1>Listing all departments</h2> | ||
<p> | ||
<%=link_to "Create new department", new_department_path %> | ||
</p> | ||
<table> | ||
<tr> | ||
<td> | ||
Title | ||
</td> | ||
|
||
</tr> | ||
<%@departments.each do |department| %> | ||
<tr> | ||
<td> | ||
<%=department.title%> | ||
</td> | ||
<td> | ||
<%=link_to "Edit", edit_department_path(department) %> | ||
<%=link_to "Show", department_path(department) %> | ||
<%=link_to "Delete", department_path(department), method: :delete, data: {confirm: "are you sure"} %> | ||
</td> | ||
|
||
</tr> | ||
<% end %> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,2 @@ | ||
<h1>Create a department</h1> | ||
<% if @department.errors.any? %> | ||
<ul> | ||
<% @department.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<%= form_for @department do |f| %> | ||
<p> | ||
<%= f.label :title %><br/> | ||
<%= f.text_field :title %> | ||
</p> | ||
<p> | ||
<%= f.submit %> | ||
</p> | ||
<% end %> | ||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<h1>Selected Department</h1> | ||
<p> | ||
Title : <%=@article.title%> | ||
Title : <%=@department.title%> | ||
</p> | ||
<%=link_to "Edit", edit_department_path(@department) %> | | ||
<%=link_to "Back to department list", departments_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% flash.each do |name,msg| %> | ||
<ul> | ||
<li><%= msg%> </li> | ||
</ul | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<% if @member.errors.any? %> | ||
<ul> | ||
<% @member.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
<%= form_for @member do |f| %> | ||
<p> | ||
<%= f.label :email %><br/> | ||
<%= f.text_field :email %> | ||
</p> | ||
<p> | ||
<%= f.label :password %><br/> | ||
<%= f.text_field :password %> | ||
</p> | ||
<p> | ||
<%= f.submit %> | ||
</p> | ||
<% end %> | ||
<%=link_to "Back to member list", members_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Edit member </h1> | ||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h1>Listing all members</h2> | ||
<p> | ||
<%=link_to "Create new member", new_member_path %> | ||
</p> | ||
<table> | ||
<tr> | ||
<td> | ||
Title | ||
</td> | ||
<td> | ||
Password | ||
</td> | ||
</tr> | ||
<%@members.each do |member| %> | ||
<tr> | ||
<td> | ||
<%=member.email%> | ||
</td> | ||
<td> | ||
<%=member.password%> | ||
</td> | ||
<td> | ||
<%=link_to "Edit", edit_member_path(member) %> | ||
<%=link_to "Show", member_path(member) %> | ||
<%=link_to "Delete", member_path(member), method: :delete, data: {confirm: "are you sure"} %> | ||
</td> | ||
|
||
</tr> | ||
<% end %> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Create a member</h1> | ||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h1>Selected Member</h1> | ||
<p> | ||
Title : <%=@member.email%> | ||
</p> | ||
<p> | ||
Title : <%=@member.password%> | ||
</p> | ||
<%=link_to "Edit", edit_member_path(@member) %> | | ||
<%=link_to "Back to member list", members_path %> |