Rails Routing Error on static single image - ruby-on-rails

I'm getting a rails routing error for a brand new image I just added. The other images in the folder all work perfectly (/public/images/%f requested at /images/%f) yet this one produces a routing error. I've checked file permissions and it's not that.
Anybody know what might cause this? I'm using the development env so caching is off and I've verified it is!
Thanks,
Jay

Ok, rebooting my vagrant VM fixed it. Don't ask me why because I don't know and it doesn't make logistical sense, in the dev env everything should be reloaded on each request.
I did nothing else except boot the VM again after Zachary asked for some fail code and it was accessible as soon as rails loaded. I spoke to a colleague shortly thereafter and he too had a very similar issue where files were not accessible until after a reboot of the machine and similarly rebooting rails itself didn't do the same job for him either.
Sorry for wasting your time!

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

Memcache working in production but fails locally

I'm working on an app with a friend and I keep running into errors in my local environment but the app works online (using Heroku). I believe memcache is causing issues in my local environment. Here's what I've done so far:
Added the memcache add-on to my app in Heroku
Installed Homebrew on my machine
Installed memcache using Homebrew with brew install memcached
Then I've restarted my app and ran the memcache process with memcached -vv.
When I access the app it works fine. Then I'll create a record. This also works fine. Then on page reload - when the record is fetched from the cache, the entire app systematically fails. Below is the error I receive (although I'm not sure how much help it is)
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
The error(s) only point to code where memcache is used. A simple user action (i.e. buy a book from a company) triggers the error and once it occurs the entire app is broken (meaning any route leads to the same error). It seems as though its just not storing/fetching the item, which makes me think the app isn't hitting memcache at all...Is it possible I have to gem install something - even though this is working in the production environment and on another dev's machine?
I'm looking for any guidance with troubleshooting memcache. More specifically, has anyone ever run into issues with local vs. production environments in regards to memcache? Any suggestions? I've thought about removing memcache from the app on Heroku, then un-installing it on my computer and then redoing everything.
I know I'm being fairly vague here but I'm not exactly sure what code to post that would help.
Thank you for any help.
After much frustration I began retracing the steps I took to install and implement memcache on my local environment. It didn't make sense how it was working online and with my friend's environment but not mine. Eventually I ran bundle install and then restarted the app and ran a new memcached process and that fixed everything. I'm still a bit confused but I guess my Gemfile just wasn't updated (even though I could've sworn it was).
I use memached without any problems in my environmens, though I do not use Herouku. To access memcached, I have installed the Dalli gem from https://github.com/mperham/dalli
Using it is rather simple.
In the file environment.rb add:
DC = Dalli::Client.new('localhost:11211')
In the application I use
DC.get(key)
DC.delete(key)
DC.set(key,value)
You will first need to test if the keys you're setting are actually getting set or not. You can use Memcached via a Telnet interface to test this.

ruby on rails unable to find interface that appears to be proplery defined

I'm brand new to ruby on rails and trying to run an application developed by others. I downloaded it from SVN it running yesterday, but today when I try to run it the first attempt to access the site's home page I get the message:
expected .../app/helpers/interface/table_helper.rb to define Interface::tableHelper.
.../lib/active_support/dependencies.rb:452:in 'load_missing_constant'
This file exists, and properly defines the tableHelper interface. Since I was able to run the program when I was setting it up yesterday, and others can run it without issue, I assume the problem I'm seeing is caused by an incorrectly set up environment rather then bad code somehow.
Can anyone suggest what I might try to figure out why rails can't seem to detect a properly defined interface?
If you were able to run the program once, perhaps something got screwed up? Have you made any changes to the code?
Alternatively, try stopping and restarting the server.
Also: what's the application? Maybe we can look at the codebase...

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.

Rails app unable to save anything after deployment

today I uploaded my app to server, and after seting it into development mode, and running of course rake tasks (rake db: migrate, and rade db: migrate RAILS_ENV="production") and well it just doesn't save anything.
The problem happens when I try to create any new items, it just goest to the listing of models...
Your question is very vague. I believe you're saying the app writes files to the server's hard drive. If that's what you're asking, I think the best guess is that something's wrong with file system permissions. Unfortunately, I can't say what is wrong without more details.
i solved it.
reason i asked was because i absolutely went through each and every one of my potential problems and took care of them, and well in the end none of them were the reason of such a failure. so then i went to the basics
and i basically had to clone my development environment on the production machine.
so i had to downgrade rails a couple of versions, and some gems too.
that took care of it, everything went on smoothly, so if anyone ever encounters such mysterous failures, give this a try.

Resources