alchaplinsky / polymer-rails

Polymer and web components for Ruby on Rails
MIT License
286 stars 80 forks source link

Calling helpers defined in ApplicationHelper #23

Closed peterhorne closed 9 years ago

peterhorne commented 9 years ago

Thanks for this project; it has made getting started with polymer in Rails really easy.

I've defined some helper methods in ApplicationHelper and am trying to call them in my custom components but get a NoMethodError. I know little about Rails' internals, but presumably ApplicationHelper is included into the scope that views are rendered from, whereas polymer-rails doesn't include ApplicationHelper?

Is this a feature that you would be interested in? If so, any pointers to start me off in the right direction would be appreciated and I'd gladly submit a PR!

alchaplinsky commented 9 years ago

ApplicationHelper methods are included into view scope, that's true. But thing is that your web components are not views, they are just assets. Which means you can easily use assets helper methods, but not helpers that you've defined for your view layer of an application. Answering the question: Should Application helpers be accessible in your web components (assets)? I'd say that we should build self contained and easy to extract web components, that do not rely on any project specific helpers or methods. But there are ways to make them available inside assets files.

peterhorne commented 9 years ago

Thanks