How to generate an expiry link in rails for edit page
I have generated a mailer functionality. I need to generate an expiry link on a mail (for the edit page for one of my models). I just need to add the expiry link in the template. How would I do that? Can anyone help me?
In mailer.template
<h5>edit startup</h5>
<%= link_to 'Edit', edit_booking_url(@booking)%>
Messages Mailer
class MessagesMailer < ApplicationMailer
def send_email(booking_users)
@booking_users = User.includes(:roles).where(roles: {:id=> 2})
mail(to: "penny12@gmail.com")
end
end
To get the booking id I have called this mailer in the booking model
def booking_email
@booking = Booking.find(self.id)
BookingMailer.send_email.deliver
end
ruby-on-rails
|
show 1 more comment
I have generated a mailer functionality. I need to generate an expiry link on a mail (for the edit page for one of my models). I just need to add the expiry link in the template. How would I do that? Can anyone help me?
In mailer.template
<h5>edit startup</h5>
<%= link_to 'Edit', edit_booking_url(@booking)%>
Messages Mailer
class MessagesMailer < ApplicationMailer
def send_email(booking_users)
@booking_users = User.includes(:roles).where(roles: {:id=> 2})
mail(to: "penny12@gmail.com")
end
end
To get the booking id I have called this mailer in the booking model
def booking_email
@booking = Booking.find(self.id)
BookingMailer.send_email.deliver
end
ruby-on-rails
What have you tried so far?
– Gabbar
Nov 26 '18 at 5:31
expiry link in the template
in mailer template?
– Gabbar
Nov 26 '18 at 5:59
What actually want to do? Please elaborate. Do you want to send a link in the email that will expire sometime?
– Mohammad Shahnawaz
Nov 26 '18 at 6:00
@Gabbar till now i have created a mailer funct which sends mail to the user to update their profile . I need to send the edit link for them in the mailer template
– Penny
Nov 26 '18 at 6:01
@Penny So just add edit link in mailer template. is there any issue for that? please post your mailer template.
– Gabbar
Nov 26 '18 at 6:02
|
show 1 more comment
I have generated a mailer functionality. I need to generate an expiry link on a mail (for the edit page for one of my models). I just need to add the expiry link in the template. How would I do that? Can anyone help me?
In mailer.template
<h5>edit startup</h5>
<%= link_to 'Edit', edit_booking_url(@booking)%>
Messages Mailer
class MessagesMailer < ApplicationMailer
def send_email(booking_users)
@booking_users = User.includes(:roles).where(roles: {:id=> 2})
mail(to: "penny12@gmail.com")
end
end
To get the booking id I have called this mailer in the booking model
def booking_email
@booking = Booking.find(self.id)
BookingMailer.send_email.deliver
end
ruby-on-rails
I have generated a mailer functionality. I need to generate an expiry link on a mail (for the edit page for one of my models). I just need to add the expiry link in the template. How would I do that? Can anyone help me?
In mailer.template
<h5>edit startup</h5>
<%= link_to 'Edit', edit_booking_url(@booking)%>
Messages Mailer
class MessagesMailer < ApplicationMailer
def send_email(booking_users)
@booking_users = User.includes(:roles).where(roles: {:id=> 2})
mail(to: "penny12@gmail.com")
end
end
To get the booking id I have called this mailer in the booking model
def booking_email
@booking = Booking.find(self.id)
BookingMailer.send_email.deliver
end
ruby-on-rails
ruby-on-rails
edited Nov 27 '18 at 8:14
Penny
asked Nov 26 '18 at 5:30
PennyPenny
339
339
What have you tried so far?
– Gabbar
Nov 26 '18 at 5:31
expiry link in the template
in mailer template?
– Gabbar
Nov 26 '18 at 5:59
What actually want to do? Please elaborate. Do you want to send a link in the email that will expire sometime?
– Mohammad Shahnawaz
Nov 26 '18 at 6:00
@Gabbar till now i have created a mailer funct which sends mail to the user to update their profile . I need to send the edit link for them in the mailer template
– Penny
Nov 26 '18 at 6:01
@Penny So just add edit link in mailer template. is there any issue for that? please post your mailer template.
– Gabbar
Nov 26 '18 at 6:02
|
show 1 more comment
What have you tried so far?
– Gabbar
Nov 26 '18 at 5:31
expiry link in the template
in mailer template?
– Gabbar
Nov 26 '18 at 5:59
What actually want to do? Please elaborate. Do you want to send a link in the email that will expire sometime?
– Mohammad Shahnawaz
Nov 26 '18 at 6:00
@Gabbar till now i have created a mailer funct which sends mail to the user to update their profile . I need to send the edit link for them in the mailer template
– Penny
Nov 26 '18 at 6:01
@Penny So just add edit link in mailer template. is there any issue for that? please post your mailer template.
– Gabbar
Nov 26 '18 at 6:02
What have you tried so far?
– Gabbar
Nov 26 '18 at 5:31
What have you tried so far?
– Gabbar
Nov 26 '18 at 5:31
expiry link in the template
in mailer template?– Gabbar
Nov 26 '18 at 5:59
expiry link in the template
in mailer template?– Gabbar
Nov 26 '18 at 5:59
What actually want to do? Please elaborate. Do you want to send a link in the email that will expire sometime?
– Mohammad Shahnawaz
Nov 26 '18 at 6:00
What actually want to do? Please elaborate. Do you want to send a link in the email that will expire sometime?
– Mohammad Shahnawaz
Nov 26 '18 at 6:00
@Gabbar till now i have created a mailer funct which sends mail to the user to update their profile . I need to send the edit link for them in the mailer template
– Penny
Nov 26 '18 at 6:01
@Gabbar till now i have created a mailer funct which sends mail to the user to update their profile . I need to send the edit link for them in the mailer template
– Penny
Nov 26 '18 at 6:01
@Penny So just add edit link in mailer template. is there any issue for that? please post your mailer template.
– Gabbar
Nov 26 '18 at 6:02
@Penny So just add edit link in mailer template. is there any issue for that? please post your mailer template.
– Gabbar
Nov 26 '18 at 6:02
|
show 1 more comment
1 Answer
1
active
oldest
votes
This is only possible for AWS attachment url by paperclip using paperclip or carrierwave gem functionality where timestamp token is passed. :D
You can still achieve what you wanted in following way
Case-1: You are mailing link and you want to give access to edit link for 20 (expiry time) min.
When you will mail, set expiry_date column in object as Time.now + 20.minute
So when he will click then he will get redirected from edit action if he had crossed expiry_date
datetime column.
Case-2: Above case-1 is not your intention & you want to expire user if he is passing expiry time to fill edit form.
So for above, when user click edit url through mail got (set expiry_date to Time.now + 20.minute
), he will be redirected to edit form. When he will submit form and action create/update
is called. It will redirect him another page without updating form.
Additional feature & conditions are needed to be added as per your cases.
Update: as per asked
- When user click edit link, in edit action set expiry_date to
Time.now + 1.day
- In
Update
action, redirect if expiry_date is passed, otherwise update data. - When re-trigger mail action, set expiry_date to nil.
Above will meet your requirement.
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475202%2fhow-to-generate-an-expiry-link-in-rails-for-edit-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is only possible for AWS attachment url by paperclip using paperclip or carrierwave gem functionality where timestamp token is passed. :D
You can still achieve what you wanted in following way
Case-1: You are mailing link and you want to give access to edit link for 20 (expiry time) min.
When you will mail, set expiry_date column in object as Time.now + 20.minute
So when he will click then he will get redirected from edit action if he had crossed expiry_date
datetime column.
Case-2: Above case-1 is not your intention & you want to expire user if he is passing expiry time to fill edit form.
So for above, when user click edit url through mail got (set expiry_date to Time.now + 20.minute
), he will be redirected to edit form. When he will submit form and action create/update
is called. It will redirect him another page without updating form.
Additional feature & conditions are needed to be added as per your cases.
Update: as per asked
- When user click edit link, in edit action set expiry_date to
Time.now + 1.day
- In
Update
action, redirect if expiry_date is passed, otherwise update data. - When re-trigger mail action, set expiry_date to nil.
Above will meet your requirement.
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
|
show 1 more comment
This is only possible for AWS attachment url by paperclip using paperclip or carrierwave gem functionality where timestamp token is passed. :D
You can still achieve what you wanted in following way
Case-1: You are mailing link and you want to give access to edit link for 20 (expiry time) min.
When you will mail, set expiry_date column in object as Time.now + 20.minute
So when he will click then he will get redirected from edit action if he had crossed expiry_date
datetime column.
Case-2: Above case-1 is not your intention & you want to expire user if he is passing expiry time to fill edit form.
So for above, when user click edit url through mail got (set expiry_date to Time.now + 20.minute
), he will be redirected to edit form. When he will submit form and action create/update
is called. It will redirect him another page without updating form.
Additional feature & conditions are needed to be added as per your cases.
Update: as per asked
- When user click edit link, in edit action set expiry_date to
Time.now + 1.day
- In
Update
action, redirect if expiry_date is passed, otherwise update data. - When re-trigger mail action, set expiry_date to nil.
Above will meet your requirement.
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
|
show 1 more comment
This is only possible for AWS attachment url by paperclip using paperclip or carrierwave gem functionality where timestamp token is passed. :D
You can still achieve what you wanted in following way
Case-1: You are mailing link and you want to give access to edit link for 20 (expiry time) min.
When you will mail, set expiry_date column in object as Time.now + 20.minute
So when he will click then he will get redirected from edit action if he had crossed expiry_date
datetime column.
Case-2: Above case-1 is not your intention & you want to expire user if he is passing expiry time to fill edit form.
So for above, when user click edit url through mail got (set expiry_date to Time.now + 20.minute
), he will be redirected to edit form. When he will submit form and action create/update
is called. It will redirect him another page without updating form.
Additional feature & conditions are needed to be added as per your cases.
Update: as per asked
- When user click edit link, in edit action set expiry_date to
Time.now + 1.day
- In
Update
action, redirect if expiry_date is passed, otherwise update data. - When re-trigger mail action, set expiry_date to nil.
Above will meet your requirement.
This is only possible for AWS attachment url by paperclip using paperclip or carrierwave gem functionality where timestamp token is passed. :D
You can still achieve what you wanted in following way
Case-1: You are mailing link and you want to give access to edit link for 20 (expiry time) min.
When you will mail, set expiry_date column in object as Time.now + 20.minute
So when he will click then he will get redirected from edit action if he had crossed expiry_date
datetime column.
Case-2: Above case-1 is not your intention & you want to expire user if he is passing expiry time to fill edit form.
So for above, when user click edit url through mail got (set expiry_date to Time.now + 20.minute
), he will be redirected to edit form. When he will submit form and action create/update
is called. It will redirect him another page without updating form.
Additional feature & conditions are needed to be added as per your cases.
Update: as per asked
- When user click edit link, in edit action set expiry_date to
Time.now + 1.day
- In
Update
action, redirect if expiry_date is passed, otherwise update data. - When re-trigger mail action, set expiry_date to nil.
Above will meet your requirement.
edited Nov 26 '18 at 8:03
answered Nov 26 '18 at 7:25
rayray
3,3561829
3,3561829
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
|
show 1 more comment
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
I am trying to achive case 2. So basically should I create a DB coulmn as expiry_date , and then set the value to some time and then send the expiry_date in the url
– Penny
Nov 26 '18 at 7:40
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@Penny Yes :) But when you want to reset expiration for his edit action again? 1. when he click edit link in mail again or 2. when you will mail link again ??
– ray
Nov 26 '18 at 7:45
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@roy when he click the edit link in the mail , he should have 24HOURS time to edit it , later it should expire. So it should reactivate when we mail the link
– Penny
Nov 26 '18 at 7:55
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny check update in my answer. :)
– ray
Nov 26 '18 at 8:03
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
@Penny Sure, be connected if you got any queries & mark answer as accepted if it works.
– ray
Nov 26 '18 at 8:10
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475202%2fhow-to-generate-an-expiry-link-in-rails-for-edit-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What have you tried so far?
– Gabbar
Nov 26 '18 at 5:31
expiry link in the template
in mailer template?– Gabbar
Nov 26 '18 at 5:59
What actually want to do? Please elaborate. Do you want to send a link in the email that will expire sometime?
– Mohammad Shahnawaz
Nov 26 '18 at 6:00
@Gabbar till now i have created a mailer funct which sends mail to the user to update their profile . I need to send the edit link for them in the mailer template
– Penny
Nov 26 '18 at 6:01
@Penny So just add edit link in mailer template. is there any issue for that? please post your mailer template.
– Gabbar
Nov 26 '18 at 6:02