include_path working fine with php, but not working in .htaccess... what gives? - set-include-path

I just moved some programs from 1 server to another. They were working on the old server... (I know that's loaded, but from what I see it shouldn't make a difference). I've looked at the "similar titles" questions, but cannot find anything like what is happening here. I would like to use the .htaccess file to set this path like I've done in the past. So far I have in PHP:
set_include_path('includes/');
echo get_include_path();
...in my htaccess I have tried:
php_value include_path includes/
..and:
php_value include_path /srv/www/htdocs/teams/includes/
However, cannot get it to work with the .htaccess file. It works with the .php file, but i'd like it to work with the .htaccess file for ease.
Any thoughts or ideas?!

Maybe your Apache or mod_php is not set up correctly:
http://www.php.net/manual/en/configuration.changes.php
Also, make sure that your current working directory "." is in the include path.

Related

Fixing broken onsite links that are not actually broken

sitemap.xml online generators cannot generate links for my domain (http://www.mm-vet.cz) saying the links on my website are broken (404).
w3.org link checker also thinks that (http://validator.w3.org/checklink?uri=http%3A%2F%2Fwww.mm-vet.cz%2F&hide_type=all&depth=&check=Check)
The best parts is that those nonexistent pages actually exist.
What am I missing?
UPDATE:
This is what my .htaccess looks like
RewriteEngine on
RewriteRule ^([a-z0-9-]+)/?$ /index.php?cat=$1 [L,NC,QSA]
This looks like a configuration issue between WordPress and Apache. WordPress is serving the content for those URLs but Apache sees them as non-existent, thus returning a 404 Not Found error. With WordPress' ability to modify permalinks within the dashboard, I don't see why you would need to rewrite your URLs in an .htaccess file. I would suggest removing what you have in your .htaccess file and configuring the permalinks in the dashboard. This should solve your problem.

How do I customize the URL path to 'subpaths' for the assets pipeline?

I notice that everything regarding Rails and Sprockets falls into the 'domain/assets/' URL, but I have this issue with certain files that are trying to get CSS and image files from:
somedomain/assets/css/{filename}
somedomain/assets/images/{img_name}
I'm trying to find some way to split up the paths of those assets so they don't all go into the same /assets path so that the URLs work. I thought maybe I could either do that in the configuration, but I didn't find anything other than renaming config.assets.prefix, or the routes.rb, because I thought something like "get /assets/css" would work but I don't know where to point it to.
In any case, at this point I'm stuck (btw, this has been in development. in production, I'm running into somewhat of a different issue where the javascript_include_tag is trying to go to /javascripts path).
I did this in my application.rb in config:
config.assets.enabled = true
config.assets.paths << "#{Rails.root}/app/assets/css"
Got the answer. Sorry if my question and examples weren't clear enough... I'm always terrible at it...
Anyways I took a look at the sprockets documentation (not the sprockets-rails docs) and this is what I did (modified config.ru):
map '/assets/images' do
environment = Sprockets::Environment.new
environment.append_path 'app/assets/images'
run environment
end
map '/' do
run Rails.application
end
Unfortunately, I don't fully understand what's going on in the config.ru other than the fact that the entire application starts here but it looks like that mapping lets me serve it up in this way (Surely, on something like AWS I can use nginx but for Heroku and overall, this seems to make things easier).

Create a global settings file in an open source rails app

I'm trying to create a rails app and have it on github, but I'm running into some trouble separating out personal settings from what I check in to git. Just like how you typically check in a database.yml.example and let people make their own database.yml, I wanted to do that with a bunch of other files (all rb files though), like secret_token and production.rb, but I didn't feel like making the setup process involve copying 15 sample files to files that actually get used.
What I ended up doing was creating a settings.yml.example file in my config dir, and putting all of those settings from the other files in there. then the setup process was just 2 copies (database.yml and settings.yml). Then I added this to the beginning of environment.rb
#allow files to read their private settings from settings.yml using SETTINGS
require 'yaml'
SETTINGS = YAML.load(IO.read(Rails.root.join("config", "settings.yml")))
and when I needed something from the file, I would just say something like
Foo::Application.config.secret_token = SETTINGS["secret_token"]
This worked fine until I tried to run rake test, when it gave me uninitialized constant Rails (NameError) from the Rails.root.join call
My question is is this a good way to accomplish what i'm trying to accomplish? And if so, is there a better place to put the code that loads the settings file? It seems like I can load it before each individual call and just add something like "unless settings is defined" after the load, but that would be annoying to have to do everywhere
Note: For anyone who's curious, the files I would have had to copy were
secret_token.rb
production.rb (for config.action_mailer.default_url_options)
devise.rb (for config.pepper)
I expect more in the future as i start using more libraries (still new to this)
this was answered in a comment, so I'll copy Thomas's answer here to make it more clear.
Both figaro and econfig (by the creator of carrierwave and capybara) are great gems for that purpose. I personally use figaro with it's config/application.yml file that is excluded from version control to great success since a few months on open-source projects.

Rails 3.1 .css.less caching error

I am quite new with Rails and I am having some irritating problems with caching of css files.
I have a .css.less file with imports inside it. It's the only stylesheet the app includes, so the other files get imported only once and by this unique stylesheet.
One of those imported .css.less stylesheets seems to be cached somewhere, because does not change in the browser when I change it's source.
I can only see the changes I made if I change something in the root stylesheet.
I have the server in development mode, so the caching should be off. I have also used <%= stylesheet_include_tag "style", :cache => false %>
I tried with Chrome and Firefox, with and without clearing their cache too. Always the same result, if I work only on that file the css the page receives when reloaded doesn't have the changes...
I also stopped the server and rm everything in the tmp folder of the app. No changes.
I am using Rails 3.1 with Ruby 1.9.3, with the less-bootstrap-rails gem. Both the root stylesheet and the imported one have .css.less extension.
What am I missing?
Thank you!
This is an area where I think the asset pipeline is broken, but I don't think there's a good fix.
If I remember correctly, to get changes in files you've included/required in your .css.less file, you need to change the .css.less file itself.
I had this on Rails 4.0.8, infuriating. The config changes mentioned above didn't help. Here's what seems to have fixed it for me:
Ensure NO FILES share a base name. For example, you have a reports.css.less and a reports.js.coffee? Doesn't matter if they're in the same directory or not. Rename or delete one of them. (I changed it to reports-styles.css.less).
Blow away your cache: rm -rf tmp/cache
Restart your Rails app.
This appears to be a decent fix but, since I don't know what's actually going on, this could be totally false and it's just working by coincidence now. Sorry this answer isn't more rigorous!
I've just came across the exact same problem.
I found that if you rename your *.css.less file (the one with the imports inside) to *.less, then this weird cacheing problem gets resolved.
Add this to your config/application.rb
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
See more at: Ruby on Rails Guide: Asset Pipeline

Wrong image path when running in a subdirectory of my Rails app

I have a rails app running in a subdirectory, like www.domain.com/sub.
The problem is that if I set a image path in my css, like
/images/my_image.png
it breaks when I upload it to my server. I need to set
/sub/images/my_image.png
then it breaks in my development environment.
The same problem occurs in my .js files.
I read something about the rails_relative_url_root environment variable, but couldn't get it to work.
Could anyone help me?
You could use URLs relative to the stylesheet. In your CSS, instead of this:
/images/my_image.png
Do:
../images/my_image.png
If you're on OSX you can set up passenger to mirror your production environment (put app in /sub folder) ... or you can look into less/sass ... I'haven't used them much but I believe they might allow you set paths for assets programmatically

Resources