New Rails App - Handling Account Settings - ruby-on-rails

I am building a new Rails-based application that will have Basecamp-like accounts for each subdomain. Each account (client/customer) should be allowed to store different settings such as a color scheme, their subdomain, their preferred authentication mechanism and so forth.
So, how should I handle the settings for each account such that I can easily add new settings later that apply to all accounts? Examples or ideas of how to build the objects and relationships (i.e. many-to-many) would be great. Additionally, if you have any good articles, I would greatly appreciate a link to those. This app needs to be highly professional and I want to make sure that I get some of these basic things right before I jump into the remainder of the project.
Thanks very much!

This question addresses a similar situation. It's worded a little differently. But if you map the question's description of a product to one of your subdomain it still feels pretty relevant. You're not explicit but with the comparison to basecamp I'm assuming that each subdomain will have it's own set of users who also have their own settings. Settings that might not be global to your application. The linked question address that too.
I see this working best as a single table for subdomain settings.
With an index on a column linking it to a customer/client/userid, another one linking it to a subdomanin.
Each option that effects subdomain design gets a column in this table. On page load just look up the row for the subdomain in the table in a before filter and things should go relatively smoothly. Adding new global options are simple. Just graft another column onto this table with an appropriate default value.

Related

Possible to skip website web.config in sub application?

In IIS I want to deploy a sub application in a website. I really don't want to bother with having to update the root website's web.config with location tags all over the place.
Is it possible to direct the sub application to just totally ignore the root website's web.config?
Okay, so that's my question. The following is just additional information that could lead someone to offer an alternate solution I haven't thought of but if possible I hope you won't judge my post on the following since, as I mentioned, the above is my question... this is just extra information for the interested:
I am deploying several websites. Each website will have an admin application which will have the same codebase. I want the admin application to be available at site1.com/admin, site2.com/admin, etc.
In the past I did something similar on another project, but instead of having sub apps I did sub domains to another site... so it would have been like site1.admin.com, site2.admin.com, etc. Nice thing about this solution was the ease of just adding additional bindings for any new site (and the application would look at host name to apply proper theming, configuration, security, etc.). I would have preferred this solution again but it just won't work this time because we can't easily secure a proper domain name for that purpose and aside from that we would prefer the user stay on the same domain name anyway just from a marketing perspective.
So ultimately my goals are:
Have the web address be "sitename.com/admin"
Only deploy the admin application to one location
Avoid spending 2 days trying to figure out how to properly configure everything so that configs don't clash and then still end up with a
few errors I spontaneously find over the course of the next week and
eventually find one that requires me to reprogram a large section of
code in order to play nicely with the root website. (If you can't
tell, I may have minor PTSD from trying something like this a couple
years back).
I mean, what would be really super is if I could have admin be its own web application and have bindings like "site1.com/admin" and "site2.com/admin" but obviously that's not possible. But maybe there are some other straightforward solutions I haven't thought of yet?

White label without code duplication?

I have a technical question I'm not sure about.
Right now I have a product / web app (rails application) that I white label to other companies. I host the white label and everything I'm just wondering how to get out of this viscous cycle of having to duplicate all my code.
If I make a change to an API on one I have to do it to the other. I'm not sure how to get around this but I think it is important.
I've thought about building a core API which will route requests to different white labels servers but I'm not sure this is the best option.
Any help offered is greatly appreciated!
It sounds as if you clone your app each time you add a new company, whereas the proper solution would be to have one app that serves somewhat different data depending on the current company.
You can use the Apartment gem if you wish to use different dbs for different companies (sort of, check docs for more details), but you need to make sure your db can handle multiple tables (PostgreSQL can't). Or you can use Acts As Tenant if you wish to scope records to a specific company.
My suggestion is to go with Acts As Tenant, as most dbs are doing well with multiple rows, but not so well with multiple tables.

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.

Checklist web app

I am new to rails and I am currently in the process of developing a check list app. I would greatly appreciate some guidance as I am currently suck in my development process and would just like some help getting me on my way.
The project I am aiming to achieve is as follows:
User has a homepage, user can add collections to watch. User can then toggle (have/don't have) products within that collection. User has no privileges to edit content of the collections or projects, all the user has access too is simply saying if they have the product or not.
Users homepage will consist of a listing of all their collections, and under their collections will be the products that correlates.
Where I am in my development:
Currently I have a 1 to many association with, Collections -> Products. I have taken care of the CRUD for collections, as well as the associated CRUD for products. I have generated a devise user model to provide myself with an easy sign in/sign up functionality.
My next steps?
That's why I'm here. I would like some guidance before I dive into further development as I don't want to drift off track. I'm not looking for specific code snippets or generators, I am basically looking for some verification that I am on the right track and perhaps some steps to help me on my way to the next bit of functionality.
If you would like to see my current code it can be found here:
https://github.com/gogogarrett/Blind-Boxd
Thanks in advance,
Garrett
It sounds like you are on the right path.
I would suggest doing the following in loosely the following order:
Make sure your models contain the right fields and types of fields for your app
Setup associations and make they are working
Go through each view and make sure the flow is correct i.e. right forms, links are displayed and data is processed correctly
Figure out how you want each page to be laid out and what's best for usability
Add some styling and polish
Throughout the whole process: write tests and use the console
Hope this helps.

Order / Priority of development in Symfony

So I've decided after much debate and research to use symfony on my next project. To sum the project up, it is an LMS (Yes, I know there are pre-built ones such as moodle but they do not have what my particular company requires). There are many modules and issues to take into consideration. My question is in what order should one start with Symfony?
Note, the database is already made and populated with data.
The Doctrine ORM?
User Authentication?
Creating the Core modules? (Courses, Enrollment, Grades)
Page security (i.e. installing the rules for who can access what page)?
Checking out the Jobeet tutorial is good advice.
If the database is already built, I would probably do something like this:
Ensure you have a plan of what "objects" and functionality the site is to have (eg. list of courses, course detail page, course search, etc). You should be able to visualise the site and have some design mockups ready. It would also help to know whether it's going to be multi-language or not.
Generate Doctrine models & form classes on the back of your db
Create home page placeholder (probably a module) and a logged-in home page placeholder (probably a module) + basic layouts for further tweaking later.
Create signup & authentication processes (so you have the core functionality of adding users, signing them in and signing them out). Use sfDoctrineGuardPlugin.
Now, start creating core modules one by one according to your plan. As you progress, you'll notice what bits make sense as partials/components and where an additional module might make sense. Add new routing rules as you go along.
Finally, add any little bits, cleanup your template HTML/CSS, JS files, etc
... this way you have a work-in-progress site that you can play around with as you go along.
If I were you, I would try to follow this tutorial : http://www.symfony-project.org/jobeet/1_4/Doctrine/en/ You can certainly match each step of the tutorial with a feature your website has.

Resources