Favicon showing up in multiple Rails apps - ruby-on-rails

I'm having an unusual problem - I uploaded a favicon into one of my rails applications into the application.html.erb file into the head using this code:
<%= favicon_link_tag 'favicon.ico' %>. This works fine, the favicon shows up, but when I close that application and open a new one into my localhost:3000, the same favicon is showing up, but there's no code in that application for it, in the head nor in the public/favicon file. Any idea how this can be happening?

That's probably because of the cached version on browser for address localhost:3000 i.e. 127.0.0.1:3000. Try changing the port number to something else. For example: localhost:3001 by running this command:
rails s -p 3001
You won't see the same favicon now.

Related

phantomJS rails controller localhost not working

I'm having a strange problem with PhantomJS and capturing a screenshot when the code is called from inside my rails controller AND it's opening a page from the same application - ie. localhost:3000/my/page. Outside of the rails controller (rails console or directly from terminal, it works fine). External URLs such as google.com, amazon.com work fine too.
What I can see:
phantomjs stops after page.onLoadStarted and never goes beyond that.
What I've tried:
Different servers:
Webrick, Puma and Unicorn and all have the same problem.
Different IPs:
I've changed the url inside the script.js file to load localhost, an internal IP and an external IP that connects to rails app. They all fail.
script.js
var page = require('webpage').create();
page.open('http://localhost:3000/my/page');
page.onLoadFinished = function() {
page.render('image.png');
phantom.exit();
}
I don't think the problem is with script.js because if I run phantomjs script.js in terminal, it works.
Is it not possible to get a screenshot from the same server that is initializing phantomjs, even if it's a different page/controller?

thin slow in development when not using localhost

I switched to using thin in local development instead of webrick.
When I access localhost:3000 it returns the page almost instantly just like webrick
But when I access myapp.local:3000 the browser spins for 20 seconds or so on each request before rendering the page. I'm not sure what it's doing during that time - the rails log shows the page being generated almost instantly - it almost seems like the browser is doing name resolution during that time or something else.
In my /etc/hosts i have
127.0.0.1 myapp.local
In webrick there was no difference between accessing myapp.local:3000 and localhost:3000.
But in thin there is the large difference mentioned above. Any theories? Much appreciated!
Look for the file /usr/lib/ruby/VERSION_OF_RUBY/webrick/config.rb and edit it.
Replace/insert the following line as a new key of the General hash.
:DoNotReverseLookup => true
Restart webrick.
Otherwise try running sudo service avahi-daemon stop
See Webrick is very slow to respond. How to speed it up? for more details

Why nginx/rails did not show me the full content?

On production server I have nginx+passenger and rails 3.1.2
Somehow it can't show we full output. I have the page with ~ 150 images and links underneath. But when page loads I can see only small part of them. Is it problem in nginx config? On my local all ok (MRI)
Nginx gzip helped me, I just turned on it in nginx.conf

Rails error "jquery.js isn't in paths .... "

I'm trying out a Q&A application written in rails 3.1 on my Ubuntu system. After I run the server (rails server), and enter the localhost:3000 url in the browser, I'm getting the following error:
/var/lib/gems/1.8/gems/jquery-rails-1.0.14/vendor/assets/javascripts/jquery.js isn't in paths:
(...."displays a list of paths including /$home/myapp/jquery-rails/ruby/1.9.1/gems/jquery-rails-1.0.14/vendor/assets/javascripts".....).
I did bundle update and it installed the jquery.js and all other .js files in that last path. But I'm still getting the same error. Any suggestions about what I might be doing wrong here?
P.S. When I enter the URL localhost:3000, it actually tries to open the URL: http://localhost:3000/session/new. Must be some application specific logic.
Remove everything in your /tmp directory and restart the Rails app.
Fixes it for me.

Rails on remote Apache server not displaying index.html.erb

I played around with Rails on my laptop (running Linux + Apache + MySQL) and had no trouble getting the Getting Started with Rails tutorial to work locally. Now I'm trying the same thing at work on a remote Mac OS X + Apache server, and things aren't quite so rosy.
I typed rails blog -d mysql to create a directory called blog in /Library/WebServer/Documents/mydirectory. The trouble is, if I go to server.com/mydirectory/public, I get the public/index.html in my browser. But, I don't get this file if I go to server.com/mydirectory/. Instead, I get a 403 error. Also, when I:
script/generate controller home index
to create:
app/views/home/index.html.erb
I am unable to view this file, whether I go to server.com/mydirectory/home/index, or if I add a new line (map.root :controller => "home") to config/routes.rb and go to server.com/mydirectory.
Am I missing something really obvious about Apache and Rails?
Apache does not support Rails out of the box. You have to get mod_rails aka Passenger installed. Or, you could just use the server that comes with Rails, which is much easier (but not suitable for production). To do this, go to your directory and do ./script/server.

Resources