-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
92 automatic profile creation for new user #111
Changes from 10 commits
feda9d5
d1981c3
821cfd8
091cc4d
2adfd30
615c908
f043ecf
3161df1
3305b0d
f3c714e
8c72243
ffe9646
5ff8855
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "administrate/field/base" | ||
|
||
class CohortField < Administrate::Field::Base | ||
def to_s | ||
Cohort.find(data).name | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
class Cohort < ActiveRecord::Base | ||
has_many :profiles | ||
has_many :users, through: :profiles | ||
|
||
def self.next | ||
(upcoming.length > 0) ? upcoming[0].id : nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Returning the ID is perhaps what you needed for this particular task, but for the purposes of building the API for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
end | ||
|
||
def self.upcoming | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check out ActiveRecord scopes. This functionality would be better as a scope inside this model than it is as a class method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
Cohort.where("start_date > ?", Date.today).order(start_date: :asc) | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="field-unit__label"> | ||
<%= f.label field.attribute %> | ||
</div> | ||
<div class="field-unit__field"> | ||
<%= f.collection_select(field.attribute, Cohort.all, :id, :name, prompt: true, selected: Cohort.next) %> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= field.to_s %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= field.to_s %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this gem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅