Activity
Posted in 2Checkout in Rails
I'll check it out and see if I can do that soon! It's definitely tough that Stripe and Braintree are mostly US based services so I totally understand your pain. 2Checkout seems like it's pretty good.
In production I typically use Passenger because it has really great performance. You can also use thin but you'll have to set it up differently than I've laid out here. Check out some things like this: http://www.rackspace.com/kn...
You should be able to just wrap it in a transaction block like so: http://api.rubyonrails.org/...
Anytime! Always happy to take a look or brainstorm with you.
I see your point there. I'd probably have a better answer playing with the code. ;)
Another solution for that would probably be to create those classes when AJAX completes the loading of the new answers (i.e., load new answer and then create a new Answer class for each)
That's probably what I would have suggested as well. Create a new Answer instance for the element you just inserted. If you're injecting the Answer HTML into the page in a create.js.erb file you could probably just do it there as long as your CS class is globally available.
And yeah, AnswerList should contain all of those. Hard to name things without seeing the HTML as well. :)
Also note, I haven't tested any of this code, so I doubt it works without a couple fixes here and there.
Ah! I got you. I would actually move things up and create a CS class that wraps the entire answer and then delegates down. Take a look at this.
class DWiz.Answer
constructor: (@answer) ->
@answerList = new DWiz.AnswerList @answer.find("[data-behavior='answers-list']")
@comments = new DWiz.CommentList @answer.find("[data-behavior='comments']")
@comment = new DWiz.Comment @answer.find("[data-behavior='comment']")
@new_comment_link = @answer.find("[data-behavior='new-comment-link']")
@setEvents()
setEvents: =>
@answer.on 'click', "[data-behavior='show-comments']", (e) => @answerList.toggleCommentsAndSetFocus(e, @answer, false)
@answer.on 'click', "[data-behavior='new-comment-link']", (e) => @answerList.toggleCommentsAndSetFocus(e, @answer, true)
class DWiz.AnswerList
constructor: (@answerList) ->
@setEvents()
toggleCommentsAndSetFocus: (e, answer, setFocus) =>
answer.commentList.toggleComments()
answer.comment.toggleComment()
if setFocus
answer.comment.setFocus(answer.offset().top)
$(document).on "page:change", (e) ->
#answerButtons = $.map $("[data-behavior='new-answer-btn']"), (item, i) -> new DWiz.NewAnswerBtn(item)
#answersList = new DWiz.AnswerList $("[data-behavior='answers-list']")
@answers = $.map $("[data-behavior='answers']"), (item, i) -> new DWiz.Answer(item)
It really doesn't need the "AnswerList" class anymore unless you plan on doing more complex things with it. You could simply move that method up to the Answer class. I kind of like having them separated because it shows much more clearly who handles what.
The giveaway for this refactoring was that you were doing parentsUntil
you got to the answer. That meant to me that you should actually have the CS class accept the answer instead, and then you could create references to all the children and they could talk to each other much more nicely. Anytime you catch yourself doing "find" outside the constructor, you can usually pull those back up to the constructor and reference them later.
Does that make more sense?
Hey Roy, Would you mind sharing what CS you've got right now? I can probably give you better pointers with that and show how I'd probably refactor it. That might make things easier.
The main reason why this is happening is because anytime the page updates, you're adding another listener to the existing items too.
What you'll actually need to do is scope your click event to the parent with jQuery. Here's a better description of how to do that: http://stackoverflow.com/a/8752376/277994
This way you won't be applying the click event to every individual item, but to the parent and then detecting the click on any of the children (which allows you to automatically target the newly added html).
It actually includes bundler, assets, and migrations in one. https://github.com/capistra...
Welcome to the gotcha that is has_and_belongs_to_many :) It's not really designed to do this. However! You can just swap the association out with as has_many through and it will work just the same:
# This might not exactly map to the same database table name, so may need to either tweak the name of this model or rename your database table
class CaseStudySite < ActiveRecord::Base
belongs_to :case_study
belongs_to :site
# Here you can just set this up so that it's automatically sorted every time
default_scope ->{ order(position: :asc) }
end
And then your other models can reference this:
class Site
has_many :case_study_sites
has_many :case_studies, through: :case_study_sites
end
Do the reverse of this for the CaseStudy model and that'll give you access to everything.
Now that you've got a model representing the join table, you can have full access to it and adjust the positions as you like.
Posted in Subscriptions with Stripe Discussion
Awesome! I haven't heard back from them yet, so maybe it was a little downtime on their end yesterday.
Posted in Subscriptions with Stripe Discussion
I'll ping Wistia and see if they have an idea why that's happening. Worst case I imagine I can re-upload it.
Posted in Subscriptions with Stripe Discussion
Hmm, I tried downloading too and it keeps cutting short. It should be almost 600MB. Not sure what's wrong. Does the video fully load for you?
I still need to walk through deploying this to production, but you should be able to use Puma just fine in production.
Yes it is. Not sure why it's not opening for you but, here's a Youtube link https://youtu.be/VvuPsXQwRrQ
Octobuild sounds like an awesome idea! I hadn't heard of it. Thanks for sharing that!
Also awesome start to the USDS project! It looks great so far. Nice and simple. :)
You can probably create a validation for it somehow. You'd need something to read the video in Ruby and check the length. Ideally people are uploading the same format of video all the time so you can do that easily.
This is a pretty awesome site to learn about it, also they have a bunch of links to screencasts: http://betterspecs.org/#scr...
You should be able to just upload them! Just make sure you don't include any validations that force images or styles that try to resize them. You'll just want to have raw uploads in that case. That's really all you need to do.