我正在尝试将我的全栈导轨应用程序一次移动到Angular页面.我正在使用ui-router(https://github.com/angular-ui/ui-router)和angular-rails-templates(https://github.com/pitr/angular-rails-templates).我假设nghaml扩展允许我继续在我的haml中使用rails helper,例如link_to,paths等,所以只需将我的haml页面复制并粘贴到模板中; 在理想的世界中,我现在处于一个页面,即客户端提供一个页面,而其他每个页面(包括它链接到的页面)仍然在服务器端提供服务.相反,我得到的错误如下:
undefined local variable or method `dashboard_patients_path' for #<Object:0x007fc87865cff0>
Run Code Online (Sandbox Code Playgroud)
和link_to等
我认为这个(带有客户端haml的angularjs)将是一个可靠的解决方案,特别是sharpper的响应,因为它似乎直接适用.
module CustomHamlEngine
class HamlTemplate < Tilt::HamlTemplate
def evaluate(scope, locals, &block)
scope.class_eval do
include Rails.application.routes.url_helpers
include Rails.application.routes.mounted_helpers
include ActionView::Helpers
end
super
end
end
end
Rails.application.assets.register_engine '.haml', CustomHamlEngine::HamlTemplate
Run Code Online (Sandbox Code Playgroud)
但是,即使重新启动服务器,也没有骰子.
思考?