The newest version of Ember.js is set to launch tomorrow (8/31/13). Here are some of the things you need to know.
Ember App Kit
Fire up a new Ember app easier than ever. Ember App Kit gives you a testing framework, Grunt tasks, and scaffold generators. This is going to make every Ember developers’ life significantly easier. In the future this will be rolled into Ember.js core. Link to the Ember App Kit.
Already in the Chrome App store, the Ember Inspector extension will let you see what your Ember app is doing in production or your development environment. You can also use the inspector on other site’s Ember apps as well. Three cheers for easier debugging of your Ember app! Link to the Ember Inspector.
Lets you create your own application-specific HTML tags. W3C is doing something similar with Web Components and the Ember team is trying to stick to the standard set by W3C. In the future when the standard is set you will be able to migrate to Web Components with ease. Read more about Ember Components in the official docs.
1,733 lines of new documentation
In the past, Ember documentation has been painfully lacking. With the addition of massive amounts of new documentation, learning to develop Ember should be a lot quicker. Link to the Ember guides.
Tentative Ember Data 1.0 beta with release of Ember 1.0
Now that Ember.js is about to go 1.0, the core team is turning their focus to Ember Data. They are rebooting Ember Data with the jj-abrams branch. There has been 32 commits already this week. Follow along with their progress here.
I recently got to play around with Stripe in my first big class project for Code Fellows. I have to say I was a little scared that I might be in over my head, but after working through a couple sample apps using Stripe and following the awesome docs on the Stripe site I felt a little more at ease.
To help anyone else looking to get started with Stripe, I thought I would share how I used it in my app to create customers with subscriptions.
First off, head on over to the Stripe site and create an account. You’re going to need your test API keys and then make a couple plans for your customers to subscribe to.
In our newly created file, we set the :publishable_key and the :secret_key using environment variables (checkout dotenv). Then we configure Stripe to use our secret key whenever we call out to their API.
For the Subscription resources, we will use a scaffold generator rails g scaffold subscription email:string plan_id:integer stripe_token:string and then we’ll create a home contoller for our forms to live rails g contoller home index.
In our subscriptions controller, we will put the code to save a subscription to our database and then the code to create a new customer and assign them to a plan with Stripe.
defcreate# get params from formemail=params[:email]plan_id=params[:plan_id]token=params[:stripeToken]# create a new subscription in the databases=Subscription.news.email=emails.plan_id=plan_ids.stripe_token=tokens.save# create a new customer and associate them with a subscription plancustomer=Stripe::Customer.create(:card=>token,:plan=>plan_id,:email=>email)flash[:notice]="You have created a subscription."redirect_tosubscriptions_path# handle errorsrescueStripe::CardError=>eflash[:error]=e.messageredirect_toroot_pathend
At the top of the create method we get the params from our submitted form. Under that, we create a new Subscription and pass in the params. Then we create a new customer with Stripe and associate them with the corresponding plan. Finally, we handle any card errors that Stripe might return.
Now we create the forms to handle our credit card data in our home/index.html.erb.
Here, we use the form_tag instead of the normal form_for because we are using Stripe checkout to handle our credit card data and submit the form. We also use a hidden_field_tag to hold the id for our different plans. The plan ids correspond to the ids we set up while creating plans from the Stripe dashboard.
Thats it! You can now sign users up for subscriptions using Stripe.
The source for this sample app can be found on GitHub and below is a video of me demoing the app I made for Code Fellows.