Tony
Joined
Activity
Posted in simple_format and Embedded content
I currently have a part of my website where people can submit user generated articles. I use simple_format to retain the layout.
e.g.
<%= simple_format(@post.content %>
As more and more of the internet uses embedded content such as Instragram posts and YouTube videos I'd like to be able to allow my users to be able to add embedded content to their articles to make them look a bit more interesting. Obviously simple_format won't allow the content to be displayed. Apart from doing something like the following which would endanger my website to exploits - what could I do?
<%= simple_format(@post.content , {}, :sanitize => false) %>
I could use a form where someone submits part of an Instragram and YouTube link but I don't think it is a very good solution as I don't know in advance at what point someone might want to add the content or how many YouTube videos they might want to have embedded on the page.
I've not heard of the Turbolinks 5-based adapter but I'm going to look into it and if you think it works then it is something that would seriously interest me as well.
I've been hoping for a while that someone like One Month (as this probably would be out of the scope for Gorails) would make a series covering creating an API for your rails app that links up to a iOS app that you also create.
I'd like to see the additional episode.
Also I'd love to be able to see how you have formatted the notification box. I'm struggling to increase the size of my notification box so it doesn't look anywhere near as presentable as yours do in the preview video.
Yes. I'm setting it to cancel at the period end and then manually visiting the customer on stripe and deleting the subscription so that I don't have to wait for the period to elapse. It is still generating a subscription.deleted webhook so I'd assume that wouldn't have an effect on it, would it?
Edit: After fiddling about with a few things it seems to be working now. Not quite sure what change did it though! Must have been a small typo or something along the way.
Next to get the hang of coupons and free trials.
Thanks once again Chris. I really appreciate you taking the time to talk to the community.
Thanks for your help.
So I've tried to implement what you said but I think there must be something wrong with my stripe.rb file as it doesn't seem to be updating my users information when the customer.subscription.deleted webhook is being sent.
Does this look correct for the event? As neither the subscription_end_date or stripe_subscription_id are being updated to nil on the users profile.
events.subscribe "customer.subscription.deleted" do |event|
if @user = User.find_by_stripe_id(event.data.object.customer)
@user.update_attribute(subscription_end_date: nil, stripe_subscription_id: nil)
@user.save!
end
end
Am I finding the user correctly?
Just noticed to cancel at the end of the subscription period you just needed to add (:at_period_end => true) to the delete command.
So if I updated my destroy method to look like this:
customer = Stripe::Customer.retrieve(current_user.stripe_id)
customer.subscriptions.retrieve(current_user.stripe_subscription_id).delete(:at_period_end => true)
current_user.update(stripe_subscription_id: nil, subscription_end_date: Time.at(subscription.current_period_end))
Where I've created a subscription_end_date and then just display to the customer that the subscription will be cancelled on this date. This should work ok right?
Chris great job with the Stripe videos. I've just been through and implemented them. :)
The next bit I need to add is to stop my users access from disappearing the minute that they cancel. If they cancel the plan - I'd like for them to retain access to the subscription features until the subscription period has finished and then their status to change back to a regular user.
Any tips on how best to implement this?
Thanks.
That was quite a lot easier than the conflicting methods I read when I googled. Just adding the following bit to has_attached_file
in the model seems to have done the trick.
:s3_headers => {"Content-Disposition" => "attachment"}
I've got a website where users can upload things such as a mp3 and the files are being stored on Amazon S3.
If a user clicks the file it just seems to open as a streaming file in the browser. I can't work out how I'd need to change my system so that it will download the file instead. Any ideas?