Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

production site being served from sub-directory #39

Closed
coriordan opened this issue Feb 1, 2012 · 8 comments
Closed

production site being served from sub-directory #39

coriordan opened this issue Feb 1, 2012 · 8 comments

Comments

@coriordan
Copy link

Is there a way to make tinymce-rails aware that the app. is being served from a sub-directory on the production server? I notice that it appends 2 additional js files into the page at runtime; langs/en.js and themes/advanced/editor_template.js. In my production setup, the assets directory sits under a sub-directory on my server, however, tinymce-rails doesn't account for this in the url path to the files mentioned above. Am I missing something?

@spohlenz
Copy link
Owner

spohlenz commented Feb 2, 2012

I don't have much experience with hosting within a subdirectory. What method are you using to do this?
Does setting config.assets.prefix = "/subdirectory/assets" help at all or does that cause other issues?

@coriordan
Copy link
Author

Hi Sam,

I'm using Phusion Passenger on my production environment. It provides an Apache directive to cater for hosting an app inside a sub-directory. Here's a link explaining its usage: http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rails_to_sub_uri

Yes, I've also tried setting config.assets.prefix = "/subdirectory/assets", but this only changes where the compiled assets are placed in the public directory.

I notice that there is a tinymcepreinit (may not have gotten this exactly right!) JavaScript function which uses 'config.assets.prefix' as its base value upon initialisation. Could this be the cause of my problems?

Regards,
Cathal.

Sent from my iPad

On 2 Feb 2012, at 01:07, Sam Pohlenz [email protected] wrote:

I don't have much experience with hosting within a subdirectory. What method are you using to do this?
Does setting config.assets.prefix = "/subdirectory/assets" help at all or does that cause other issues?


Reply to this email directly or view it on GitHub:
#39 (comment)

@spohlenz
Copy link
Owner

spohlenz commented Feb 4, 2012

This should be fixed in the latest version (gem will be released soon).

When you precompile your assets, make sure you set the relative url root environment variable:
rake assets:precompile RAILS_RELATIVE_URL_ROOT=/subdirectory

@spohlenz spohlenz closed this as completed Feb 4, 2012
@coriordan
Copy link
Author

I've upgraded to version 3.4.8 of the Gem and tried to use your suggestion about precompiling assets and the two files in question, 'editor_template.js' and 'en.js' are still being referenced directly from the assets directory:

i.e. http://example.com/assets/tinymce/themes/advanced/editor_template.js?3.4.8
http://example.com/assets/tinymce/langs/en.js?3.4.8

they are not taking into account the sub-directory.

@spohlenz
Copy link
Owner

spohlenz commented Feb 7, 2012

Couple of things that might help:

  • Try clearing out your asset cache: rake assets:clean && rake tmp:cache:clear
  • Try putting the env setting first: RAILS_RELATIVE_URL_ROOT=/subdirectory rake assets:precompile
  • What version of Rails?
  • How are you including TinyMCE into your page (e.g. via application.js or including directly)?

@coriordan
Copy link
Author

Hi Sam,

I'm running Rails 3.1.3 and I'm including TinyMCE through app/assets/javascripts/application.js

I'm deploying through Capistrano; using the 'deploy/assets' rake tasks to handle asset precompilation.

cheers,
Cathal.

On 7 Feb 2012, at 00:25, Sam Pohlenz wrote:

Couple of things that might help:

  • Try clearing out your asset cache: rake assets:clean && rake tmp:cache:clear
  • Try putting the env setting first: RAILS_RELATIVE_URL_ROOT=/subdirectory rake assets:precompile
  • What version of Rails?
  • How are you including TinyMCE into your page (e.g. via application.js or including directly)?

Reply to this email directly or view it on GitHub:
#39 (comment)

@spohlenz
Copy link
Owner

spohlenz commented Feb 7, 2012

How are you setting the environment variable in your deploy.rb?

I believe the following should work:

set :asset_env, "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=/subdirectory"

Is that similar to what you have now?

@coriordan
Copy link
Author

Hi Sam,

I just upgraded to Rails 3.2.1 and added the following entry to 'config/environments/production':

config.relative_url_root = "/sub-uri"

and tinymce-rails is serving the necessary javascript files from the correct location. All is well :)

I found this link that gives some more detail on same problem I was experiencing:

http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/

I hope this comes in handy for others who may have the same problem.

cheers,
Cathal.

On 7 Feb 2012, at 11:30, Sam Pohlenz wrote:

How are you setting the environment variable in your deploy.rb?

I believe the following should work:

set :asset_env, "RAILS_GROUPS=assets RAILS_RELATIVE_URL_ROOT=/subdirectory"

Is that similar to what you have now?


Reply to this email directly or view it on GitHub:
#39 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants