Adding Spree to an Existing Rails App - ruby-on-rails

I have a rails app that I've built that I would like to add an estore too. My plan was to do it using spree. A few considerations:
I already have a user model, and am using devise for authentication
I want to be able to include related products on various point of the
site (for example, if the user is in the 'cooking' section of the
site, show 'cooking' related products.
I am hosting it on heroku, and I'd like for the store to be at:
http://store.myurl.com
Does anyone have a good jumping off point? I've never worked with spree before, and it seems that most of the documentation is oriented towards people starting an app from scratch with spree. My google searching hasn't yielded too much that is useful.
Can anyone give me tips or point me in the right direction?
Thanks,

I think you may get stuck trying to stick two apps together, particularly if you have two authentication systems running.
I might consider getting Spree up and running first then adding the functionality from your existing app in bit by bit ensuring you 'extend' Spree so upgrades don't break your customisations.
And if you think your custom code may be useful to others you could make it into a Spree plugin.

Related

integrating a discourse message board with an existing rails site

I'm looking at integrating a message board for a site I'm developing in rails. The new discourse board looks interesting http://www.discourse.org/ but there isn't much information about integrating into another site either via oauth2 or sso or perhaps using a rails engine type system. Has anyone succesfully set this up with an app like this?
thx
edit t
Is there a roadmap for how this integration could take place in the future? Parts of it look really intriguing but would like some more info on how this use case could be handled.
edit 2
Since this question is getting a fair amout of traffic, I want to add this post http://meta.discourse.org/t/integrating-discourse-with-current-user-database/6669 which goes over the SSO attempts going on at discourse currently. I have also been in contact with the people at thougtbot about their implementation.
I was interested in the same issue but here's what I found on Github issues:
The easiest way to get it running would be to install Discourse
outside of your app. We do offer the full source code if you want to
integrate with your existing login system, but I imagine it would be a
fair amount of work at this point.
Right now we haven't focused much on production deployments since
we're pre-beta and want to make sure people have a super easy upgrade
system in place to stay on top of security holes.
Not done any app with Discourse, but if their site does not provide a lot of info did you browse the Git Repository https://github.com/discourse/discourse it provides plenty of information and resources links like these ones :
Discourse Developer Install Guide (Vagrant) :
https://github.com/discourse/discourse/blob/master/docs/VAGRANT.md
Developer Advanced :
https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md
Admin quick Start : https://github.com/discourse/discourse/wiki/The-Discourse-Admin-Quick-Start-Guide
Hope it can be of some help for you
Cheers

HOW: Static company website with Rails

I have a really stupid question in my mind.
I have used Wordpress to create a website for long time, but I dont want to use it anymore. And now I am looking for little bit different approach. Otherwise, I am quite new in Ruby on Rails. I have read some books and I am not feeling in this matter so confident. So, here is the deal:
My friend asked me to create a simple website for his company. He wants only super simple static website which will contains these pages:
Home
Products
Contact
Each page will contain simple information and there is no need to implement contact forms and other basic functionalities. I also want to deploy this app on Heroku, because he has not a lot of money and we are looking for free hosting. Moreover, I think that the best approach in this matter will be some kind of CMS which will help him to edit the website.
The overview of final solution:
Static webpages with simple CMS
Using twitter bootstrap for basic layout
Deploy on Heroku
I appreciate every contribution in this matter.
Thank you
Everything you have said suggests that you should stick with WordPress. It's perfectly capable of presenting a non-blog static website (use Pages instead of Posts) and there are some excellent themes available. WP has, over the years really become a CMS that's also good for blogging. There are other tools like Drupal that may be appropriate.
I set up a WP site with almost exactly the same goals for some very non-technical people; with a little training they eventually learned how to manage the site, upload images, add content, grant permissions to others, and do a lot of other pretty cool stuff. I have been using Rails since 2007, but for that case, it was not the right solution.
Rails is a very (very!) sophisticated web development environment used to build complex and scalable dynamic websites. With power comes a level of complexity several orders of magnitude higher than WordPress. Even if you use refinerycms you still need to do a lot of complicated setup, and need to know a lot of stuff. Even if you're using Heroku and following a RailsCast like the one for refinerycms, you'll undoubtedly hit some wall where you really need to understand more ... Rails is alluring this way -- seems simple.
If you are using this a reason to learn Rails, and are willing to invest some time, then by all means go for it. But if you want a simple solution, it's not the way. Learning Rails is like learning to fly a plane, but harder.
For static pages with rails, you can use High Voltage gem. You can find the detailed usage of this gem in this blog post . Once you create the pages, then you can easily deploy your app as like normal rails app in the heroku.

rails user notifications for several models

I'm still learning rails but want to be sure I'm heading in the right direction. For several of my models I want to let a list of users know that updates have been made when a new record is created for example. I'd like to tie this to an email and in-app notification(doesn't need to be AJAX), next page refresh is fine.
I've been reading up on observers some and I think that's what I want but they seem somewhat controversial based on the blogs I've read. Services like Pusher seem to be overkill for my needs.
Would this be a good solution for this scenario? Also, can anyone point me to some example code that I could emulate?
Thanks!
Check out Rails Cast if you are trying to learn. Best free code base I have seen. Also check out this book another great learning tool. Agile Web Development with Rails (2nd edition).There might be some newer ones out but I have not checked.

Spree as a mountable engine

So, we want to rearchitect a portion of our site as a Rails app. The original plan was to have a main "site" app, with a number of plugin apps (Rails 3.1 Engines) with compartmentalized functionality -- a store component, a social/forums/chat component, etc. Also, we wanted to put themes/styling in a gem so that our web designers could modify the site appearance and some minor layout tweaks without having to "know Rails." Initially, this was going well; we created the main architecture and plugins and the theme gem, and it was all playing nicely together; cross-cutting functionality like auth was put in the main "site" app and was consumable by the plugin apps, giving us a single sign-in for the site (a design requirement).
Our initial plan for the store component was to use the Spree (http://spreecommerce.com/) since it had, out of the box, 95% plus of the functionality we needed. However, there's a catch -- Spree is distributed as a mountable engine, but it's also an app. Meaning that not only does Spree mount inside an app (which is not a problem, in fact it's behavior we were counting on), but it depends upon being in control of the main app. Looking into the "why" for this behavior, it seems to depend upon two core pieces of functionality. The first chunk of functionality is some SEO permalink rewrite functionality that has to go into middleware; we could hack things so that our main app included this chunk of code (even though this would begin to entangle store functionality across our entire site, muddying the "Spree as a mountable engine" story... more on that in a moment).
More complicated is Spree's use of Deface to do theming and customization. While this is "clever" (note quotes), it really makes the integration of Spree kind of a nightmare; either you follow the path of least resistance and make Spree an entire store to itself (which completely breaks our story of "the store is just one part of our site, and plays nice with the rest of the site, including auth, theming, etc."), or you have to hack the hell out of Spree.
Not only that, but Spree doesn't follow the standard Rails Engine routing paradigm, where routes are isolated beneath an engine root (if you look in the lib's routes.rb file, you can see that it uses Rails.Application's routes, instead of an Engine's routes). This means that we couldn't have www.oursite.com/store/...all_the_spree_goodness, we'd have to have www.oursite.com/spree_owns_the_sites_routes...
So, has anyone else tried this? We LOVE Spree and would like to use it as our store. But it's starting to look that there's no real way to "integrate" it with the rest of our site aside from maybe some proxying magic with nginx or something like that (which is a separate nightmare, since we're hoping to host on Heroku, and then we have to figure out how to integrate multiple disparate apps into one DB -- for single sign-in auth -- and an HTTP front router).
Spree devs, we LOVE your code, but is there any work being done to make it an actual, for-real Rails Engine, as opposed to a stand-alone app that just happens to package all of its features into Engines? Without the ability to integrate it into an existing site (including not "owning" the app, being able to have all of its routes partitioned off, and so on), there's just no way we can use it :(
TIA.
I'm the Community Manager for Spree, so I think I may be able to answer your question.
Yes, there is work going on that will allow Spree to be a true Rails engine. In fact, that was my first task that I did when I was hired by Spree. The work is on the master branch (https://github.com/spree/spree) and we're looking to release this code as a 1.0.0.rc around Christmas time.
With this code, a couple of changes have been made. For starters, Spree is now a proper Rails engine meaning that you can now have it mounted at /spree or /shop or /whatever and Spree's cool with that. Secondly, all the models and other classes are namespaced so they won't conflict with anything in your application.
I'm not sure what you mean about Deface being "clever", though. What problems do you forsee with this? If you want to override an entire view you could do this by overriding the path in app/views/spree/products/show.html.erb. Mind you, this overrides the whole view, and if you only want to override a part of it that's when you'd use Deface.
Could you perhaps elaborate on the issues you're having with Deface? Would be interested to help you sort them out.
Thanks for using Spree!

Is it possible to create sub-applications in Ruby on Rails 3 or something like slices from Merb?

Does Rails 3 have anything akin to slices in Merb, or areas in Django where there is a layer of organization above the controller? I heard at some point that they may allow hosting one rails app within another but I can't find any information on that in the pre-release material. Any hints on how to do something like this?
You're right there doesn't seem to be a lot of official documentation on it yet. But yes, you can have application slices -- they're called engines in Rails. Actually they've been available in Rails since 2.3. Currently, you basically make a plugin that has a complete application structure and set up your routes in there to "mount" your app against a specific URL. In Rails 3, engines are basically first-class objects in the Rails stack. I believe they can still be plugins but you will also be able keep it away from your application in a separate gem and require it in your application much more easily. You should be able to find stuff pretty easily on teh Google, but here's an oft-linked but informative reference: https://gist.github.com/af7e572c2dc973add221

Resources