Skip to content

Commit

Permalink
Added User, Team, and Captain models to admin
Browse files Browse the repository at this point in the history
  • Loading branch information
amanmibra committed Jan 3, 2019
1 parent 19995c1 commit 9bfb0d4
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 6 deletions.
15 changes: 15 additions & 0 deletions app/admin/captains.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ActiveAdmin.register Captain do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes]
# permitted << :other if params[:action] == 'create' && current_user.admin?
# permitted
# end

end
28 changes: 28 additions & 0 deletions app/admin/teams.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ActiveAdmin.register Team do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes]
# permitted << :other if params[:action] == 'create' && current_user.admin?
# permitted
# end
permit_params :name, :captain_id, :tent_type, :tent_number, :passcode

index do
column :name do |team|
link_to team.name, admin_team_path(team)
end
column :captain do |team|
link_to team.captain.user.name, admin_user_path(team.captain.user)
end
column :tent_type
column :tent_number
column :passcode
end

end
31 changes: 31 additions & 0 deletions app/admin/users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ActiveAdmin.register User do
# See permitted parameters documentation:
# https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes]
# permitted << :other if params[:action] == 'create' && current_user.admin?
# permitted
# end
permit_params :email, :name, :team_id, :sign_in_count

index do
column :name do |user|
link_to user.name, admin_user_path(user)
end
column :email
column :team do |user|
link_to user.team.name, admin_team_path(user.team)
end
column :sign_in_count

actions
end



end
2 changes: 1 addition & 1 deletion config/initializers/active_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
config.site_title = "Gthc"
config.site_title = "GTHC"

# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
Expand Down
10 changes: 5 additions & 5 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,35 @@
name: 'Team 1',
captain_id: 1,
tent_number: 1,
tent_type: 'blue',
tent_type: 'Blue',
passcode: 'ABC123'
)
team_2 = Team.create!(
name: 'Team 2',
captain_id: 2,
tent_number: 2,
tent_type: 'black',
tent_type: 'Black',
passcode: 'ABC123'
)
team_3 = Team.create!(
name: 'Team 3',
captain_id: 3,
tent_number: 3,
tent_type: 'white',
tent_type: 'White',
passcode: 'ABC123'
)
team_4 = Team.create!(
name: 'Team 4',
captain_id: 4,
tent_number: 4,
tent_type: 'dirty black',
tent_type: 'Dirty Black',
passcode: 'ABC123'
)
team_5 = Team.create!(
name: 'Team 5',
captain_id: 5,
tent_number: 5,
tent_type: 'dirty blue',
tent_type: 'Dirty Blue',
passcode: 'ABC123'
)

Expand Down

0 comments on commit 9bfb0d4

Please sign in to comment.