Two rails apps sharing a model folder

前端 未结 7 522
半阙折子戏
半阙折子戏 2020-12-23 22:14

I have two rails apps running off the same database, one which runs the client and one which provides an admin interface.

Both the apps have the exact same models de

7条回答
  •  别那么骄傲
    2020-12-23 22:23

    Just curious - why not have one app with two modes?

    I have one application that looks like one of a dozen different apps, branded differently and with different functionality, depending on which URL you're coming in on and who you log in as. My users have roles and I added a method to ActiveRecord::Base that gives you the current user. Thus I can do stuff like:

    MAX_VOLUME = current_user.admin? ? 11 : 10
    validates_inclusion_of :volume, :in => 0..MAX_VOLUME # Admins can go to 11!
    

    And in the views, stuff like this:

    <%= render :partial => common_tabs %>
    <%= render :partial => admin_tabs if @current_user.admin? %>
    

提交回复
热议问题