Re: [Rails] Help with single page application structure

94 views
Skip to first unread message

tamouse mailing lists

unread,
Apr 3, 2013, 7:45:09 PM4/3/13
to rubyonra...@googlegroups.com
On Tue, Apr 2, 2013 at 8:43 AM, Johan Vauhkonen
<johan.v...@gmail.com> wrote:
> I'm planning on creating a single page application using AngularJS on the
> client side.
>
> I'm not sure if I should use Rails as it is, or the Rails API gem or some
> other solution.
> Anyone got any suggestions on how you structured your application?
>
> Should I be using the asset pipeline? Or should all client side stuff be
> separated from Rails?
>
> I'll be creating a simulation engine for this application to simulate
> results that the application will show.
> Using Rails I thought I'd make the simulation engine a Rails Engine to
> separate the logic from the rest of the application.
> Is that a good idea? Can the Rails API gem make use of engines?

A colleague and I were having a very similar discussion today. He
allowed as he just wrote his own asset pipeline, combining together
all the various compilers and converters and such into something
pretty simple that he's using under Sinatra. He had said he initially
thought about using Rails minimally for the asset pipeline, but then
came up with this.

Johan Vauhkonen

unread,
Apr 4, 2013, 2:35:03 AM4/4/13
to rubyonra...@googlegroups.com
I think for me, using Sinatra would mean I'd have to write a lot of things that Rails bring which I don't want to.

tamouse mailing lists

unread,
Apr 4, 2013, 8:16:13 AM4/4/13
to rubyonra...@googlegroups.com


On Apr 4, 2013 1:35 AM, "Johan Vauhkonen" <johan.v...@gmail.com> wrote:
>
> I think for me, using Sinatra would mean I'd have to write a lot of things that Rails bring which I don't want to

Agreed; we were talking alternatives and for his needs, he really only needed the pipeline.I was just trying to illustrate that stripping Rails isn't the only direction one can go.

Johan Vauhkonen

unread,
Apr 4, 2013, 8:20:42 AM4/4/13
to rubyonra...@googlegroups.com
Is it a viable alternative to separate client and back end?

To have AngularJS take care of everything client side and Rails take care of only the back end?

tamouse mailing lists

unread,
Apr 4, 2013, 8:31:09 AM4/4/13
to rubyonra...@googlegroups.com


On Apr 4, 2013 7:20 AM, "Johan Vauhkonen" <johan.v...@gmail.com> wrote:
>
> Is it a viable alternative to separate client and back end?
>
> To have AngularJS take care of everything client side and Rails take care of only the back end?
>

Absolutely, you can go so far as to have your SPA initial download be a static index.HTML in ../public, and just have your routes speak JSON to the Angular requests. I'm working on this currently only using backbone and underscore.

Walter Lee Davis

unread,
Apr 4, 2013, 9:02:58 AM4/4/13
to rubyonra...@googlegroups.com
There's a few Railscasts that cover Ember and Angular and they all start from this premise. You use Rails, but you don't do that much in it. It's just there providing the persistence, and all of your real work happens in the public folder.

Walter

Johan Vauhkonen

unread,
Apr 4, 2013, 9:22:51 AM4/4/13
to rubyonra...@googlegroups.com
I've initially made a HomeController that serves the initial index view (with it set as the root in routes) but I think I like the /public way better.

Thanks for the idea!

Johan Vauhkonen

unread,
Apr 5, 2013, 3:13:20 AM4/5/13
to rubyonra...@googlegroups.com
Do you disable Rails routing somehow when using client-side routing?


On Thursday, 4 April 2013 14:31:09 UTC+2, tamouse wrote:

RonPhillips

unread,
Apr 5, 2013, 7:50:36 AM4/5/13
to rubyonra...@googlegroups.com
This tut shows a combined approach: http://blog.berylliumwork.com/2012/09/tutorials-on-angularjs-and-rails-2.html?view=classic (Don't forget to download angular-resource and require it in application.js. Other than that, everything worked.)

I'm fiddling with it right now, because I don't really want a single page app, and I really, really don't want a weird URL structure.
Reply all
Reply to author
Forward
0 new messages