we have developed an rails project using rails 3 and mysql, it has images, css and javascript (jquery) and it is working fine in windows xp environment.
But when i migrated the code to ubuntu, the images, css ( applies partially) and javascript (jquery) are not loading. i am running in development mode.
I have included the js and css like this:
<%= stylesheet_link_tag "jquery-one", "ctlCalendar", "application", "jquery.treeview" %>
<%= javascript_include_tag "jquery-1.6.2.min", "jquery.rails", "jquery.treeview"%>
Here the error i am getting:
Started GET "/images/LoginImage.png" for 127.0.0.1 at 2011-08-13 01:02:04 +0900
ActionController::RoutingError (No route matches "/images/LoginImage.png"):
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.0ms)
Started GET "/Images/Back_Login.gif" for 127.0.0.1 at 2011-08-13 01:02:05 +0900
ActionController::RoutingError (No route matches "/Images/Back_Login.gif"):
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.1ms)
can anyone help me to solve this problem?
Thank You,
Sudhir C.N.
Ubuntu, and other Linux versions, have case-sensitive file names, while Windows XP doesn't.
This means while LoginImage.png and loginimage.png are the same in Windows, they are not the same in Ubuntu. That's probably the cause of your problem.
The same applies to path names – /images and /Images are completely different paths in Linux, so make sure not to mix them up.
Related
I'm trying to deploy a Rails 3 app which includes jQuery Mobile. It works fine in development, and I understand that it needs to precompile the JS and CSS for production. I'm getting the following error:
Started GET "/orders/mobile" for 127.0.0.1 at Wed Jun 06 14:22:40 -0400 2012
Processing by OrdersController#mobile as HTML
Rendered orders/mobile.html.erb within layouts/mobile (642.9ms)
Completed 500 Internal Server Error in 1122ms
ActionView::Template::Error (jquery.mobile isn't precompiled):
5: <head>
6: <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7: <title>Company Orders</title>
8: <%= stylesheet_link_tag 'jquery.mobile' %>
9: <%= stylesheet_link_tag 'jquery.mobile.structure' %>
10: <%= stylesheet_link_tag 'jquery.mobile.theme' %>
11: <%= stylesheet_link_tag 'http://fonts.googleapis.com/css?family=Ubuntu' %>
app/views/layouts/mobile.html.erb:8:in `_app_views_layouts_mobile_html_erb__605278794_69818059003840'
app/controllers/orders_controller.rb:330:in `mobile'
app/controllers/orders_controller.rb:329:in `mobile'
I've read the usual stuff, but there are so many things wrong here, I hardly know where to start:
I had the JQM stuff in app/assets, but have since moved them to vendor/assets. They get seen by the precompiler -- I know because it will complain about them on various tries -- but they never seem to get precompiled (in either location).
I've tried *= require_tree ../../../vendor/assets/stylesheets in application.css. I don't really want it included in every page hit, so I'd like to include it in the layout, but I'm just trying to get it precompiled somehow.
I've tried *= require jquery.mobile[[.css].erb] in application.css.
I've tried config.assets.precompile += %w( [[./]vendor/assets/stylesheets/]jquery.mobile.* ) in config/environments/production.rb.
As a last-ditch effort, I've removed the ".erb" from jquery.mobile.css.erb, and removed the <% asset_data_uri %> tags to see if it would compile. It passes the rake assets:precompile command, but still gives me the same error.
I don't want to turn off precompiling for JQM; I want it to work. (I really need to speed this page up.) However, I can't find any guide on how to get JQM elegantly inserted into a Rails 3 app (with precompiling), and I've exhausted every avenue I can think of in trial and error. Surely someone has done this and knows the right way to go about it.
My fundamental problem here is that I need to have some assets precompiled for production, but NOT included in every page hit. Here's what I've figured out:
If I didn't mind JQM being served with every page, I could either put the files in app/assets and let require_tree . do its magic, or leave those files in vendor/assets, and require them individually in application.js. If I want to put them in vendor/assets and NOT specifically require them in application.js, I can use config.assets.paths << "#{Rails.root}/vendor/assets" in production.rb, and (apparently) require_tree in application.js will process this tree as well. This still rolls them up into the compiled application JS "ball," but leaves them distinct on the filesystem.
The proper way to incorporate jQuery Mobile for specific pages -- and keep its files separated in vendor/assets -- seems to be to use both a config.assets.paths << "#{Rails.root}/vendor/assets" directive and a config.assets.precompile += %w( jquery.mobile.* ) directive. This will get the JQM files precompiled, but NOT rolled up into application-(hash).js and application-(hash).css. (They'll be individual files in public/assets.) Then you can do specific javascript_include_tag's and stylesheet_link_tag's in a layout specially for mobile views.
Big finish: I had upgraded to Rails 3.2.5 because I saw some security report on 3.2.3. I rolled back to 3.2.3 and -- incorporating what I learned above -- I was able to finally get it working. I also tried 3.2.4. Apparently there's a regression in > 3.2.3 that interferes with precompiling.
We're upgrading our app from Rails 2 to Rails 3.1, and I'm having trouble with the asset pipeline.
I've got the following in my config/application.rb:
if defined?(Bundler)
Bundler.require *Rails.groups(:assets => %w(development test))
# Bundler.require(:default, :assets, Rails.env)
end
# Enable the asset pipeline
config.assets.enabled = true
# config.assets.prefix = "/assets"
config.assets.paths << "#{Rails.root}/public/images"
config.assets.paths << "#{Rails.root}/public/stylesheets"
config.assets.paths << "#{Rails.root}/public/javascripts"
config.assets.version = '1.0'
And then this in development.rb
# Do not compress assets
config.assets.compress = false
config.assets.debug = true
I know this isn't the desired behavior for the pipeline, but we are doing it this way to make sure that when we merge the upgrade back into our master branch, all the old files are accounted for properly.
I then have the following file, "all.css," in my public/stylesheets directory:
/*
*= require ezform
*= require jquery-ui-1.8.9.custom
*= require thickbox
*= require yui-upload
*= require styles
*/
I am calling it from within my layouts/application.html.erb file like so:
<%= stylesheet_link_tag "all" %>
Loading things up in a browser, however, I get no styles (or javascript, for that matter). Firebug and Chrome tell me that the .css and .js files are being looked for in "/assets" - it's like the pipeline isn't searching through everything and bundling it like it should.
The error looks like this:
GET http://localhost:3000/assets/jquery-dependent.js 500 (Internal Server Error)
If I move "all.css" into /app/assets, it still won't find it. Moving it into /assets stops the error, but the stylesheet doesn't compile and I still don't get any styles in my browser.
There's also a slew of errors that look like this in my log:
Started GET "/assets/defaults.js?body=1" for 127.0.0.1 at 2011-12-22 14:35:36 -0600
[2011-12-22 14:35:36] ERROR NoMethodError: 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.each
/Users/kevin/.rvm/gems/ruby-1.9.2-p0#media3/gems/rack-1.3.5/lib/rack/handler/webrick.rb:71:in `service'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/kevin/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
cache: [GET /assets/defaults.js?body=1] miss, store
Served asset /defaults.js - 200 OK (1ms)
What am I missing?
sigh It was memcached. I tured it on (memcached -d) and now all my assets are appearing. I'm not sure why, so I'd love some explanation. Otherwise, it's working.
There are a while bunch of settings that need to be added into the development and application config files for the pipeline to work correctly.
Check out the last section of the pipeline guide for details of these.
Once you've done that I suggest that you change the manifest names to application.css and application.js as these are the default names and you'll run into fewer problems starting with those. Edit your question if it still does not work and I'll see if I can help after that.
I am using Fancy box (jquery plugin ) to view video files in my application. I have placed the plugin under vendor -> Javascripts -> javascripts.
but when I run the development server I get the following errors:
Note: I have not modified anything: I just moved the files from my desktop and placed them under vendor/javascript folder
ActionController::RoutingError (No route matches [GET] "/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.js"):
Rendered /Users/jayparteek/.rvm/gems/ruby-1.9.2-head#default/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.9ms)
ActionController::RoutingError (No route matches [GET] "/jquery.fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.css"):
Rendered /Users/jayparteek/.rvm/gems/ruby-1.9.2-head#default/gems/actionpack-3.1.1/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)
You should use the gem 'fancybox-rails'
I have in
<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/assets/application.js" type="text/javascript"></script>
but when I go to http://localhost:3000/assets/application.css
Routing Error
No route matches [GET] "/assets/application.css"
P.S. Rails 3.1.0.rc4, ruby 1.8.7
Seems Sprockets / Rails 3.1 were acting up for me w/ ruby 1.9.2-p180 ... updating to Ruby-1.9.2-p290 seemed to stop the issue.
Maybe not related to your issue... but useful for anyone else having that issue using those versions of Rails & Ruby.
I found that I had something similar going on after updating to Rails 3.1 this evening. I was working on a project that didn't use ActiveRecord, so I had a modified my application.rb to exclude it. The line that usually reads require 'rails/all' to only include the parts I needed, like this:
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "rails/test_unit/railtie"
This list has changed in Rails 3.1 to include Sprockets, the core component to making the asset pipeline work. I got the asset pipeline serving the serving content as expected by adding this line to the bottom of the list:
require "sprockets/railtie"
After restarting, /assets/application.js and other assets began working as expected.
Note: if you have a custom setup like this, be sure to open the railties gem and look at the contents of lib/rails/all.rb which may have changed (as in this case).
Your scripts and styles will be loaded from the public folder. Drop the assets folder under public and you should be good to go.
In the application layout file, if you have
<%= stylesheet_link_tag "/assets/application" %>
which gives
No route matches [GET] "/assets/application.css"
TRY changing it to
<%= stylesheet_link_tag "application" %>
I had to add the following line in application.rb:
config.assets.enabled = true
in bottom of class Application < Rails::Application
Currently i'm developing 2 Rails::Engines 1 blog (for fun) and 1 csv importer and mapper. I made them with enginex and jeweler into a gem. I installed them locally and i included either 1 of them in an empty rails 3.x project and it's working fine!
The thing i want to do know is include both gems in 1 rails 3.x project. This all works doesn't raise any errors but here is the problem.
When i go to my "/blog" routes everything is rendered perfectly. But when i go to my "/csv" route i dont see any layouts. When i look at the development.log i see this:
Started GET "/csv" for 127.0.0.1 at Sun May 01 20:23:19 +0200 2011
Processing by CsvEngine::ImportsController#index as HTML
Rendered /Library/Ruby/Gems/1.8/gems/csv_engine-0.0.1/app/views/csv_engine/imports/index.html.erb within layouts/application (0.8ms)
Completed 200 OK in 24ms (Views: 23.1ms | ActiveRecord: 0.0ms)
This all looks fine, but i dont see any of my html. But when i put a <%= raise "hell %> inside my index.html.erb it gets raised. So i'm baffled here, both my engines work. All my rails logic works but i dont see my html inside the index.html.erb.
The strangest thing is when i include "csv_engine" gem without the blog gem in a empty rails 3 app everything works fine and i get the html views.
I even tried overwriting the views from within my empty host app e.g. app/views/csv_engine/imports/index.html.erb with some other html in it but this also doesnt work.
Does anyone has any idea what this could be?