[英]How to re-use models and controllers across rails applications
We are coming up with a new twitter bootstrap
theme for new functionality within our application. 我们正在为应用程序中的新功能提出一个新的twitter bootstrap
主题。 Our existing functionality will use the existing theme with models/controllers
. 我们现有的功能将使用现有主题和models/controllers
。
But I would like to re-use the existing models/controllers
and use the new twitter bootstrap theme for the new functionality. 但我想重新使用现有的models/controllers
并使用新的twitter bootstrap主题来实现新功能。
How do I go about addressing this and maintain the code bases (the old app will be on host:port1 and new app will be on host:port2) 我该如何解决此问题并维护代码库(旧应用将在host:port1上,新应用将在host:port2上)
Edit : 编辑:
My old rails application under public/javascripts public/stylesheets
. 我在public/javascripts public/stylesheets
下的旧Rails应用程序。 Some of the views are under app/views/foos/
Some of the views are under app/views/bars/
一些视图位于app/views/foos/
一些视图位于app/views/bars/
I would the new views under app/views/cars/
How should I reference my new index files to point to the new theme/css
under app/assets
我将在app/views/cars/
下找到新视图,如何引用新的索引文件以指向app/assets
下的新theme/css
You can switch between css manifest files. 您可以在CSS清单文件之间切换。 So for new theme it could be like 所以对于新主题,它可能像
new_theme.css
/*
*= bootstrap_alternative_theme
...
*/
old_theme.css
/*
*= bootstrap_original_theme
...
*/
And layouts/application.html.erb 和layouts / application.html.erb
<% if request.port == port1 %>
<%= stylesheet_link_tag "old_theme" %>
<% else %>
<%= stylesheet_link_tag "new_theme" %>
<% end %>
To add to benchwarmer answer, you might have the html and also the javascript modified so you can define a new layout and toggle between old and new layout as per your needs. 要增加替补答案,您可能需要修改html和javascript,以便定义新的布局 ,并根据需要在新旧布局之间切换。
But for compiling those assets, assuming your assets are not named application.css or application.js, add a line in your application.rb 但是对于编译这些资产,假设您的资产未命名为application.css或application.js,请在application.rb中添加一行
config.assets.precompile += %w(new.css new.js)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.