Redmine 404 on some pages - ruby-on-rails

I have installed Redmine on a shared Bluehost account and at first sight it seems to be working.
I followed both of these tutorials: https://my.bluehost.com/cgi/help/redmine and http://www.redmine.org/projects/redmine/wiki/RedmineInstall
But just as i started navigating around i noticed that there seem to be a routing problem because some of the pages are returning a 404 error code for a reason i don't understand yet.
The error log shows no information regarding this problem.
The url is on redmine.example.com , the user/pass are still admin/admin.
I have identified that any URL regarding a project is failing, for example:
http://redmine.example.com/projects/new
http://redmine.example.com/projects/21
http://redmine.example.com/projects/21/issues
(Currently i have reset the DB for privacy concerns)
In order to prove my theory that it was regarding the projects issue, i went into the projects controller file found in app/controllers/projects_controller.rb and tried to put some abort("Foo") here and there but i couldn't see my message with any of the links that are not working so i thought maybe the problem is not there and is probably in the routing process. So i checked the config/routes.rb file and comparing it with my local version they seem identical
I am not sure what to try next as i am not a Ruby developer. Let me know what kind of info you need in order to help debug this problem.

Eventually i got it working by using FastCGI.
In order to do that, i simply created a .htaccess file and a dispatcher.fcgi as shown in the answer here : Redmine 2 on Hostmonster apache fcgi: Rails application failed to start properly
Don't forget to SetEnv GEM_PATH to your ruby gems path in your .htaccess file and it should work after restarting (pkill dispatcher.fcgi)

Related

Rails host app doesn't see engine layout

What I want to do works on my OSX dev machines and on a staging server. However, I encounter problems on the production server.
I have a Rails Engine which I have created, maintained, and used over the years: https://github.com/allesklar/tkh_admin_panel
It works fine on many apps and I have been porting it to this new website as of late. For admin views, my controllers render the 'admin' layout which is located on this engine.
Everything has gone great until I tried to deploy to the site's production server. I get the following error:
ActionView::Template::Error (no implicit conversion of nil into String):
This exception occurs in the line with the following code:
render layout: 'admin'
I can't pinpoint any differences in gems, rbenv ruby versions, or any other factor from one setup to the next.
I've tried to reset the binstubs and done a number of other things.
No matter what I do, it works on the staging server and not on the production server.
Please point me to some directions where I can investigate further.
UPDATE ---
The scope of the problem has changed entirely since now I'm experiencing the same issue on my development machines.
I therefore think the problem lies in the host app/gem relationship. The same version of this gem works fine with some other Rails host sites of mine.
Any ideas welcome.
Try to recompile all assets. If you can (it's a prod server) delete all assets and manifest and re-deploy.
Try to delete all cache, if you are using page or fragment caching, perhaps your deploy system is not cleaning it correctly.
Simply reboot the system (simple action that fixed a lot of problems in the past).
And if nothing works, try to display the full backtrace to see where this is happening

Blank Page Hosting Wordpress in Heroku

I've followed Ry Walker's instructions in Setting up a Wordpress blog on Heroku as a subdirectory of a Rails app also hosted on Heroku.
Everything seemed to work fine at first (I was able to access the Wordpress app through the /blog subdirectory), however after a few minutes I started getting a blank page as result of both /blog and [blog-app].herokuapp.com
I have gone through the steps twice and the same problem persists. Unfortunately, Heroku logs does not show any errors. I am afraid that this is related to the RewriteBase directive.
Has anyone faced similar problem?
I was having a similar problem, and it ended up being related to a bug in the rack-reverse-proxy gem where the content length header was getting corrupted.
There have been two people that have offered up fixes to the gem, but the fixes haven't been merged into the master branch. I forked the branch, copied the fix somebody had suggested, and used my version of the gem in the Gemfile. It's been working great ever since.
Here's the change you'll need to make in lib/rack/reverse-proxy.rb
# ensure content length header is correct
res.content_length = body.bytesize

Passenger "No such file to load" error for Model

I'm having a problem with deploying a Rails 3 app to a Passenger/Apache2/RVM server running Ubuntu 11.10.
I'm getting the error:
A source file that the application requires, is missing.
...
Error message: No such file to load -- Goal
Exception class: LoadError
Goal is one of my Rails Models.
I've seen a lot of people with a similar error message, but their issues seem to relate to missing bundles/gems - not model files! Their problems were resolved by ensuring permissions were set up correctly, so to that end I've got:
Apache running as www-data, as is Passenger. RVM is installed as www-data and I've chown'd the entire web app directory to www-data.
I've been wrestling with this for some time now and am really out of ideas - if anyone has any suggestions I'd be very grateful!
You might probably have the file structure of your Rails app wrong. Are you sure you have the "goal.rb" file within {your_app_root_url}/app/models/ ?
To me, if I am seeing the error when you view the app in browser, it seems like your rails app and passenger(with apache2) are working fine. The other possibility is you might be looking at wrong app folder which passenger is set up to.
It's hard to tell what's wrong. Please provide more details of how you set up your passenger with your rails app directory. Also it would help if you could show what's inside your app (app structure) and what's inside goal.rb model file.
Well I've solved it. Turned out that a work around for a problem with yaml encoded model archives (i.e. an explicit require of Goal) in a completely unrelated Model was causing the error to appear. Looks like it only rears its head in production - probably due to the differences between the class loaders used in development vs. production.
Tough one to find... the stack trace didn't include a reference to where the problem actually was!

Newbie help with Rails/Ruby. Totally lost! (Mongrel related, I think) 503 Errors

I am on the verge of actually hiring someone to fix this
for me, but I hope it doesn't come to that.
I have no experience with Rails/Ruby, but I do know my way around
computers in general.
I have two domains on one server (Hostingrails, I am beginning to hate
them more and more these days).
My secondary domain works 100% fine.
But for the past few days, my primary domain has not been working, it
has been giving me 503 Errors. I've opened a ticket regarding this, and
they told me to SSH into my server and reset "Mongrel". I've done this
using the code they gave me; "mongrel_rails start -d -e production
-p13930"
It seemed to have worked, but the problem was still there. The log says
the error is something about:
"require': no such file to load -- dispatcher (LoadError)"
I've re-opened a ticket concerning this, and Hostingrails basically told
me that it is not their problem anymore and that it's solely up to me to
fix it. Brilliant.
So I spent a good part of the day looking and changing things around
through SSH (probably wasn't the greatest idea) but I still keep getting
503'd on my website.
However, I recently found out that my index file HAS to be index.html,
or it will not render the page. index.htm or index.php will result in a
503. If I set the index page to index.html, it worked. Which is strange,
my htaccess file allowed for all.
Another problem, I think I have inadvertently changed something in my
settings while I was SSH'd in. When I do "bundle install" it installs
the gems into my own private webspace, for example /home/mywebsite. But
I believe on my shared plan, all the rails/ruby/gems etc are all under
/usr/local/rvm/gems/ruby-1.9.2-p0/ which I don't think I have access to.
How do I change the directory to the default one? For example, before
the error log said:
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in
`require': no such file to load -- dispatcher (LoadError)
Now it says:
/home/mysite/.gems/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in
`require': no such file to load -- dispatcher (LoadError)
I think that's everything for now. Here are the rails installed on my
server by the host:
Installed at (3.0.0): /usr/local/rvm/gems/ruby-1.9.2-p0
(2.3.8): /usr/local/rvm/gems/ruby-1.9.2-p0
(again, I think my mongrel is looking in the wrong place, as my gems are
now being installed into /home/mywebsite/ instead of
/usr/local/rvm/gems/) Is it possible to someone reset the settings I've
changed back into my host's default one?
Would anyone be willing to take the time and try and fix this with me? I
am pretty annoyed at Hostingrails, since I didn't do anything to create
this problem, and they are outright refusing to help me. Why is my
primary domain getting 503 errors when my secondary domain works fine?
Mongrel is not compatible to ruby 1.9.2. You need use a fork of mongrel to use it https://github.com/kyusik/mongrel_cluster
I advice you to user thin/passenger or unicorn instead of mongrel.
I found a little blog post about problem with Mongrel and ruby 1.9.2 http://xaop.com/blog/2010/08/04/deploying-rails-3-on-ruby-1-9-2/
Maybe you could try using Ruby 1.8.7 - it causes less trouble in general at this time.
Not an answer to your question in particular, but if you're new to Ruby and Rails, then hosting your own stuff can be a daunting task.
Instead, try Heroku - simply push your Rails app to Heroku with git and you're good to go. They support custom domainnames for free.

Passenger problem: "no such file to load" -- /config/environment

I've been researching this one and found references to similar problems here and there, but none of them has led to a solution yet. I've installed passenger (2.2.11) and nginx (0.7.64) and when I start things up and hit a Rails URL, I get an error page informing me of a load error:
no such file to load -- /path/to/app/config/environment
From what I've found online this appears to be some sort of a user/permissions error, but I've tried all the logical fixes: I've made sure that /config/environment.rb is not owned by root, but by a webapp user. I've tried setting passenger_default_user, I've tried setting passenger_user_switching off. I've even tried setting the nginx user, though that shouldn't matter much. I've gotten some differing results, but nothing's actually worked. I'm hoping someone may have the magical combination of settings and permissions for this. I may try backing down to an earlier version of Passenger, because I've never had this issue before; it's been a little while since I set up Passenger though.
Thanks for any suggestions.
EDITED: See below for the answer I stumbled on.
Modern Passenger prefers Rack to Rails. If you have a config.ru in your Rails application, Passenger will try to load it as a Rack application. This may be causing problems. In particular, your error message refers to config/environment -- note the lack of the .rb extension typical in a Rails application.
Try moving config.ru out of the way if it exists.
Naturally, it just took me posting the question to stumble onto the answer. In order to provide info for anyone else searching on this problem, I'll post some details here.
The relevant lines from the nginx.conf:
user www-data; # in order to have nginx not run as root
passenger_default_user www-data; # likewise for passenger
root /opt/foo/app/current/public;
The key at this point is to make sure that the application files are owned by www-data, in particular config/environment.rb because apparently Passenger looks at its owner to determine who to run as. This might mean that the passenger_default_user entry is irrelevant? But it's good to have it there as documentation of intent anyway, perhaps.
Finally, make sure that the parent directories of your app are all reachable by www-data -- in my case the system default setup had left a directory 0700, which I'd missed.

Resources