Different apps for website and control panel? - ruby-on-rails

I'm developing my first useful rails app at the moment and have a general question.
How are bigger applications like digitalocean.com or invisionapp.com set up:
Are the website and control panel always two different applications?
If not, what is the setup to seperate these two in one app on different subdomains, for example with rails?
I hope the question is clear, I wasn't able two find an answer.
Thanks in advance!

Check you this question Rails routing to handle multiple domains on single application
I'm not sure about digital ocean architecture, but I think that they have multiple apps.
At the beginning of learning rails it is not necessary to build website and control panel as different apps.
Let them be a single app, just locate them on different subdomains.
And with help of constrains in routes.rb you can route requests to different controllers, depending on required domain.

Related

Mautik hosting best practice

I am new to Mautik and therefore need a guidance on the same.
Where should we setup mautik... on some folder or on sub domain to main site or a separate domain? How does the landing pages and forms gets its URL? Can it be embedded on another site on another domain or is it required to be hosted where mautik is hosted?
Moreover does single installation of mautik can be used for two or more different businesses site... which are not relevant.. and mainly a different customer for a marketing company? Or is it better to install mautik per business?
Can we track interactions from mobile app too using mautik?
First thing, I expect you are talking about Mautic and not Mautik.
You are free to choose whatever type of hosting you want, personally I Like to use independent container(could be lightweight) however I have seen people hosting on shared hosting as well.
If you are hosting on say example.com the landing page url will be example.com/landing-page same goes for all elements of mautic.
Yes forms can be embedded on other websites with a completely different domain. say example-something-else.com, you will need to put your tracking script on other site's head to make it work better. I for example check out this small tutorial https://tutorialsjoint.com/mautic-wordpress-integration/ it shows how you can use it in wordpress.
No it is not required that wherever you want to use mautic form should be on same host or domain.
However I recommend to use subdomain if usually just to save the hassle of buying a new domain and keeping the landing page urls more relevant. https://www.youtube.com/watch?v=K8lWaCabH1w this video shows how tracking works, it'll help you understand little better. Also here's official documentation: https://docs.mautic.org/en/contacts/manage-contacts/contact-monitoring.
You can use use one instance to manage multiple businesses I know people who are doing it but when the number of contacts, segments, campaigns, form, emails, landing pages grow with time it becomes a hassle to keep it clean. You can use category and a specific naming convention to keep them organized. But in a good way i will recommend to keep different instances in long run.
I am not sure about mobile apps but ideally it should be possible using tracking script or tracking pixel, perhaps you will need to turn off CORS restrictions.
I hope it was helpful.
Cheers!
No, you must use a VPS with Devian or Ubuntu, In a shared hosting it can cause problems. If you send many emails.
Landing pages can be made in html and pasted or edited in Mautic.
To use it in more sites you must create a user for each one, with their respective different email.

show one application on 2 site with different front ends but same back end, in ROR hosted on heroku

I have an application in rails and hosted on Heroku. Now , what I want is that the application can be accessed from 2 different domains, when the application is accessed from suppose a.com it should have a specific frontend, and when accessed from b.com it should display some other frontend. The backend should be same for both.
To achieve this I suppose there is only one way I guess, which is to have two different application with same backed code, and same database(I am using PostgreSQL). I need some help on how Do I achieve this, if not, then some other alternative.
You could have only one app for both if it's easier for you. I would then suggest you configure config/routes.rb to respond differently according to the domain name.
See another answer about it here: Rails routing to handle multiple domains on single application
And the Advanced Contraints in Rails here: http://guides.rubyonrails.org/routing.html#advanced-constraints

Multisite application in Rails (like shopify.com)

I would like create web app like shopify.com.
User can pickup subdomain(or domain), theme and have own store.
How can I do this?
Create main application, deploy it automatically like new standalone version and update it via git?
I'm using Rails 3.
Thanks for your advice.
Based on replies:
When I choose to use only one application (without multiple instances) and give user his subdomain, it will looks like their own website. But everything will be in one database (It's good idea?). And how can I have multiple themes in Rails app?
Take a look at LocomotiveCMS, specifically the routing system. Locomotive actually hosts multiple sites inside a single rails application. It does this by inspecting the request URL when it comes in and setting the current_site variable with the site which is set up to handle the domain. Then the current_site is actually just an object which contains all the pages, contents, settings, etc. for the specific site being served up.
So to answer your question, I think a good solution is to give your rails app the ability to serve up multiple sites based on the domain. It's not that hard, and it seems less fragile to me than trying to automatically deploy new instances of an app.
So far I have understood, you want to let your users have their own subdomain, different theme but the functionality would be same right. Users just need to have a feel of something of their own.
Well definitely, you need to have a single application that supports multiple subdomains.
A quick googling gave me [ http://37signals.com/svn/posts/1512-how-to-do-basecamp-style-subdomains-in-rails ]. May be you can get some insights from here.
For example if your service is http://www.myfi.com, a brief idea can be:
When a customer is registering, you should let him choose his subdomain. And the newly created account will be associated with this subdomain with a url. Say, http://customer1.myfi.com.
You should register for domain *.myfi.com so that anyone in the world hit with anysubdomain.myfi.com, it comes in your application.
Then from the url part, you should identify the subdomain (customer1) that is being used, and need to set that in session.
Now when someone will try to login, you must verify the account in the context of that subdomain's account.
In fact, all following actions need to be handled in the context of the subdomain's account.
Just tried the gather a glimpse of the implementation here. If you have confusion about something specific, share that also.
Edit:
Whenever you are thinking about multiple theme, you must have simple design which is completely driven by css and js. The app/view files should contain only content and HTML nodes with class names or ids.
Generally a UI designer can put more helpful ideas about how to make such theming mechanism. But all I can feel is, based on the chosen theme by customer, you have to load different css and js.
Actually the strategies can be indefinitely sophisticated and scalable, but its always wise to start with something easy. Then ideas will automatically evolve into better ones.

Should I split my Rails app?

I have two tasks both using rails:
To make an inventory app to help employees keep track of inventory
To make a website for the company for customers to visit and gain a bit of knowledge about our product
My plan is to have the inventory app for each branch of the company to have a domain like this:
branch1.example.com
branch2.example.com
branch3.example.com
and for the customer-facing website to simply be www.example.com
My question is, should I make two separate rails apps, one for the inventory app and one for the customer-facing website? Or would it be easier to manage the two as a single combined app? The two apps would not be likely to share much code.
And if I were to split my apps, how would I be able to host both of my apps using a single domain as seen above (with the use of subdomains) with heroku?
Thanks!
Well, there's not really one right answer, but being experience with rails, I would recommend one app.
If you split there will be many times you'll have to copy and paste common code (becomes unmanagable). Plus you'll deal with either a shared database or multiple databases.
Not splitting, you can use a wildcard domain and access the current subdomain via request.subdomain to easily do whatever logic needs to happen per subdomain. Also you will only need to create the Product model once.
In short, all the mentioned requirements sound tightly coupled enough that one app would be easiest.

How to consolidate multiple rails application and share ressources

I have thi intranet I developped back then with PHP.
I handles multiple apps and tools (blog, link sharing, file sharing, events, clendar...), and a big user autenthication system for logging in and authorisation management.
I'd like to start re-building it with Rails.
I don't want to build one big app.
I'd like to build the site as multiple smaller apps, sharing a few common ressources like the user administration system, templates, layouts and navigation...
Rails Engine provide a way to embed an app into another.
I guess I could have a "main" app, embedding all other apps.
But I don't feel it's the right way (I may be wrong) if I have 10-15 different apps.
How would you do it ?
Thanks.
We've created applications that are split into 2 - the user facing site and an admin site. We just made 2 separate sites that have the same db and models and their own views and controllers.
This works pretty well and gives us the freedom to treat each site differently in terms of security and deployment.
I don't have any experience in going farther than that.
Check out ActiveResource - it is designed to allow you to use RESTful webservices as if they were ActiveRecord objects.
I'm working on a project now with a bunch of separate sub-apps that are pure web services (no UI). There's one "main" application that has all the UI and handles login/authentication, and then accesses the others via ActiveResource.
You can share the models between projects adding
config.autoload_paths << Dir["SHARED_MODEL_PATH/app/models/*"]
to your application.rb config file.
Or you can check the tutorials about ActiveResource such as:
http://andywaite.com/2010/12/22/activeresource-layered-rails-app
http://wholemeal.co.nz/blog/2010/03/08/active-resource-associations-and-nested-resources/
http://ofps.oreilly.com/titles/9780596521424/activeresource_id59243.html

Resources