We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
notification_setting
Is your feature request related to a problem? Please describe.
The Readme has this example:
s = User.first.notification_setting s.settings[:enabled] = false
But when I tried this example after adding notification-settings to an existing project, I got this error instead:
notification-settings
main > s = User.first.notification_setting => nil main > s.settings[:enabled] = false NoMethodError: undefined method `settings' for nil:NilClass
Describe the solution you'd like
It would be nice if a settings target/object could safely assume that it always has an associated notification_setting.
It looks like this callback was added in order to help ensure that a notification_setting always exists for new users:
before_create :create_notification_setting
... but that doesn't help in the case of pre-existing user records.
I propose (instead of that) overriding notification_setting such that it builds a new setting if one doesn't already exist:
def notification_setting super || build_notification_setting end
I've tried it locally and it works fine...
Describe alternatives you've considered
Update the migration generator to create settings records for any existing [user] records.
The text was updated successfully, but these errors were encountered:
Would you be willing to submit a pull request?
Sorry, something went wrong.
[jonhue#33] Automatically build notification_setting if object does…
97c6fcb
…n't have one yet
Sure! Submitted #40...
[#33] Automatically build notification_setting if object doesn't ha…
bb46dab
…ve one yet (#40)
No branches or pull requests
Is your feature request related to a problem? Please describe.
The Readme has this example:
But when I tried this example after adding
notification-settings
to an existing project, I got this error instead:Describe the solution you'd like
It would be nice if a settings target/object could safely assume that it always has an associated
notification_setting
.It looks like this callback was added in order to help ensure that a
notification_setting
always exists for new users:... but that doesn't help in the case of pre-existing user records.
I propose (instead of that) overriding
notification_setting
such that it builds a new setting if one doesn't already exist:I've tried it locally and it works fine...
Describe alternatives you've considered
Update the migration generator to create settings records for any existing [user] records.
The text was updated successfully, but these errors were encountered: