sharing code between server and client

35 views
Skip to first unread message

Thijs de Vries

unread,
May 7, 2014, 7:33:23 PM5/7/14
to opa...@googlegroups.com
What is the best way to share ruby between server and client? I've been using symlinks but I feel there has to be a more idiomatic way.
Thijs

Steve (Gmail)

unread,
May 7, 2014, 7:34:16 PM5/7/14
to opa...@googlegroups.com
I use symlinks and it seems to work fine for me.
"You must be the change you want to see in the world." Mahatma Gandhi

blog: http://steve.stewdle.com/blog
twitter: @boberetezeke
On 5/7/14 6:33 PM, Thijs de Vries wrote:
What is the best way to share ruby between server and client? I've been using symlinks but I feel there has to be a more idiomatic way.
Thijs
--
You received this message because you are subscribed to the Google Groups "opalrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opalrb+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Adam Beynon

unread,
May 8, 2014, 1:46:03 AM5/8/14
to opa...@googlegroups.com
Either symlinks or adding the server dir to the sprockets load path. Both have the same effect. I prefer using the load path as it allows more control, I.e. I can ensure that it is the last path in the load path so any client side assets in the standard assets directories take precedence.

Sent from my iPhone

Jared White

unread,
May 14, 2014, 5:17:55 PM5/14/14
to opa...@googlegroups.com
Yeah, adding to the sprockets load path is a good idea. What I did was add app/models/shared folder, and then put:

config.autoload_paths += %W( #{config.root}/app/models/shared )
config.assets.paths << "#{Rails.root}/app/models/shared"

into config/application.rb

Then you can just require 'some_model' in an Opal file and that will work, plus you'll be able to use the model in the Rails server context as well.
Reply all
Reply to author
Forward
0 new messages