News for hackers. Stuff that matters.
Re:Rails 4.0: Final version released by bti on Tuesday June 25, 2013 @11:30AM (#5940146)
Maybe a little off topic... I just started a small project using Angular and Rails, learning both from scratch as I go. I am using Rails as a purely JSON server and handling all the templates in Angular and doing requests over $http. Is it worth using Angular just for the UI niceness and using more of Rails? I need things like authentication and sessions but at its roots it is a single page app. Would any of this new Rails 4 turbolinks stuff help?
Re:Rails 4.0: Final version released by vinceguidry on Tuesday June 25, 2013 @11:43AM (#5940268)
If you want to learn Rails, you should choose a project that will teach you Rails. If all you're going to do with it is serve up JSON, then you're not really going to learn anything and will needlessly overcomplicate your app. Just use something like Sinatra in this case, Sinatra will get out of your way and allow you to focus on the front-end.

Using Angular with Rails is definitely a Good Thing(TM), but you really need a large enough project to justify, something both front- and back-end heavy. My current project is large enough to benefit from both, but unfortunately, I chose jQuery and Sinatra. Feeling the pain, for sure.

Re:Rails 4.0: Final version released by steveklabnik on Tuesday June 25, 2013 @12:09PM (#5940450)
There is waaaay more to Rails than the view layer. If 'all you're going to do is serve up JSON', then you'll be using a very large amount of Rails: https://github.com/rails-api/rails-api#why-use-rails-for-jso...
Re:Rails 4.0: Final version released by vinceguidry on Tuesday June 25, 2013 @12:31PM (#5940605)
Hmm. Thanks for this.
Re:Rails 4.0: Final version released by steveklabnik on Tuesday June 25, 2013 @11:54AM (#5940345)
The Rails-API project is here to help! http://github.com/rails-api/rails-api

I don't personally know of anyone using Angular + Turbolinks, so I can't answer that.

Re:Rails 4.0: Final version released by playing_colours on Tuesday June 25, 2013 @12:31PM (#5940606)
Thanks, I'm building Angular.js app and adopting Rails 4 for api backend, Will Rails-API be updated for Rails 4 ?
Re:Rails 4.0: Final version released by steveklabnik on Tuesday June 25, 2013 @12:52PM (#5940757)
It should work today. If it does not, it's a bug.

By the way, ActiveModel::Serializers is part of the Rails API project[1], and we'd love some thoughts on how to make it work well with Angular.

1: https://github.com/rails-api/active_model_serializers

Re:Rails 4.0: Final version released by janus on Tuesday June 25, 2013 @02:30PM (#5941459)
The only issue that's been biting me when using ActiveModel::Serializers and AngularJS is that we must manually return the json with the root: false option set, otherwise the AngularJS $resource provider doesn't work correctly.
Re:Rails 4.0: Final version released by lentil on Tuesday June 25, 2013 @04:40PM (#5942298)
If it helps you can make that the default for all your serializers, by doing something like this in an initializer:

    ActiveSupport.on_load(:active_model_serializers) do
      ActiveModel::ArraySerializer.root = false
      ActiveModel::Serializer.root = false
    end
Re:Rails 4.0: Final version released by danmaz74 on Tuesday June 25, 2013 @12:55PM (#5940781)
Re:Rails 4.0: Final version released by bti on Tuesday June 25, 2013 @12:42PM (#5940695)
Wow that looks great. Are there any benchmarks as to how much faster it is compared to a vanilla Rails app?
Re:Rails 4.0: Final version released by steveklabnik on Tuesday June 25, 2013 @12:54PM (#5940772)
It's difficult to benchmark, to be honest: Rails apps depend on so many things, there are too many variables. I'd love to hear from some people who have tried it in their apps though!

I'm more interested in it as a place to explore best practices and work on useful things around names, than the speed aspects.