Error Compiling Assets Rails 3.2.13 - ruby-on-rails-3

When I go to my rails app in my browser I am getting the following error:
Error Compiling CSS Assets
ArgumentError: no time information in "2013-09-20T10:02:37-05:00"
I have been able to work around this error by clearing the cache and cleaning my assets and restarting Apache. However, I cannot do this anymore.
This is not my first Rails project, but this is the first time I have run into this error, and I cannot figure out how to get around this. I should also add that I have been developing the app for a week now, without this error. I have made no changes to my any of my assets.
I figured I'd add the error message from my logfile.
Completed 500 Internal Server Error in 15066ms
ActionView::Template::Error (no time information in "2013-09-25T12:55:42-05:00"):
2: <html>
3: <head>
4: <title>JournalReview</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___63165616209989497_70158248592280'
Rendered vendor/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.3ms)
Rendered vendor/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
Rendered vendor/ruby/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (9.6ms)
Thanks.

I solved this problem. I had overridden the "!" operator to appear as the factorial notation used in math. I had tested this, because I had expected this to interfere with the false logic, I did not expect this to through an error in Time / Date.
Anyway, I removed that operator, from my module, and everything worked.

Related

gmap4rails - can't find file underscore / Gmaps is not defined

I am following the simple tutorial here: https://github.com/JonKernPA/gmaps
I keep getting the error:
couldn't find file 'underscore'
(/app/assets/javascripts/application.js:16)
with the following line highlighted:
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
I tried following the suggestions posted in
Gmaps is not defined in rails 4 + gmaps4rails 2.0.3
and I get the same error with the error with the same line highlighted.
When I try to remove the line
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
from application.html.erb, I get the error "Gmaps not found"
Any help appreciated, thanks.
Github link: https://github.com/chiefkikio/circus/
Found a solution. Had to install gem 'underscore-rails' and then bundle it and restart the rails server.
Not a tutorial project, but I use gem 'underscore-rails' (cf https://rubygems.org/gems/underscore-rails) to satisfy gmaps4rails' dependence.
The minified version of Underscore has this line at the end of the file:
//# sourceMappingURL=underscore-min.map
Chrome's developers tools will try to download underscore-min.map when encountering this line. Users won't see this error, unless they open developer tools.
If you want to get rid of this error, either add underscore-min.map to your project (https://github.com/jashkenas/underscore/blob/master/underscore-min.map) or remove that line from underscore.min.js
I also faced the issue and this is what was the reason for me:
The order of required files in my application.js was wrong. I required
//= require_tree . before gmaps. And since I didn't wait until page load in my controller_name.js file, it was loaded first, trying to use Gmaps before the latter was defined.. I thought it might help, but.. I run into another couple issues with ".. is not defined". After small research here is the solution:
wrap you whole custom js in callback for window.load event. I used it with this line:
google.maps.event.addDomListener(window, "load", callback)
Hope this will help

How do I get jQuery Mobile precompiled for Rails 3 production?

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.

Rails 3 asset pipeline: How to prevent some asset files from being loaded for everyone (eg. browser-specific)

I want to server the 'excanvas.min.js' file only to the Internet Explorer and not to other browsers.
So I did in my application.html.erb:
<!--[if lt IE 9]>
<%= javascript_include_tag 'excanvas.min'
# Excanvas for use of Canvas in IE up to version 8
%>
<![endif]-->
<%= javascript_include_tag 'application' %>
But I get the following error (in production):
Completed 500 Internal Server Error in 3ms
ActionView::Template::Error (excanvas.min.js isn't precompiled)
The error also happens when forcing Rails to precompile the file with
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
config.assets.precompile += %W(excanvas.min.js,other_file.css,even_anotherfile.js)
in 'config/production.rb'. What am I doing wrong?
I could do a
//= require excanvas.min
in the application.js. But that would include the file for every browser...
Info: I made an update from an Rails 3.0-Application.
The problem is in the following line
config.assets.precompile += %W(excanvas.min.js,other_file.css,even_anotherfile.js)
the %W is a shortcut for creating an array, and the items need to be separated by a space. In your case you are adding the string excanvas.min.js,other_file.css,even_anotherfile.js to the precompile list.
So just replace the line as follows:
config.assets.precompile += %W(excanvas.min.js other_file.css even_anotherfile.js)
just try to add <%# %> for line and .
i think they will be displayed as comment.
OR
you can do that will js.judge the browser with js and load the corresponding css file

Devise not working after update, Tests via capybara complete without failures

I'm quite new to RoR and programmed a couple of things before discovering Test-Driven-Development. So I tried to write some tests with guard-rspec and capybara. All was fine, but I got some deprecation warnings for devise (had version 1.1.rc02), so I updated it (now having latest version 1.4.5).
These were the warnings:
Running all specs
DEPRECATION WARNING: Using form_for(:name, #resource) is deprecated. Please use form_for(#resource, :as => :name) instead. (called from _app_views_devise_sessions_new_html_erb___942904761_2291541620_0 at /Users/xonic/Documents/work/ror.ror.at/app/views/devise/sessions/new.html.erb:3)
FDEPRECATION WARNING: Using form_for(:name, #resource) is deprecated. Please use form_for(#resource, :as => :name) instead. (called from _app_views_devise_sessions_new_html_erb___942904761_2291541620_0 at /Users/xonic/Documents/work/ror.ror.at/app/views/devise/sessions/new.html.erb:3)
.DEPRECATION WARNING: Using form_for(:name, #resource) is deprecated. Please use form_for(#resource, :as => :name) instead. (called from _app_views_devise_registrations_new_html_erb__1735759005_2291086140_0 at /Users/xonic/Documents/work/ror.ror.at/app/views/devise/registrations/new.html.erb:3)
So I changed
<%= form_for(resource_name, resource, :url => registration_path(resource_name)) do |f| %>
to
<%= form_for(resource, :url => registration_path(resource_name)) do |f| %>
and got rid of the warnings. So far so good, I continued with my tests and did not try to open the application in the browser myself.
I'm not sure what happened then but all of a sudden, when trying to open the application in the browser, i get the following error message:
NoMethodError in Slides#index
Showing /Users/xonic/Documents/work/ror.ror.at/app/views/layouts/application.html.erb where line #27 raised:
private method `split' called for #<Class:0x10c023278>
Extracted source (around line #27):
24:
25: <div class="gopro">
26:
27: <% if user_signed_in? %>
28: Signed in as <%= link_to current_user.username, user_path(current_user) %>. Not you? <%#, user_slides_path(current_user.username) %>
29: <%= link_to "Sign out", destroy_user_session_path %>
30: <% else %>
So obviously, Devise is in trouble... no idea why. Funny thing is, when calling save_and_open_page while testing the app, a browser window opens with the application displaying correctly and no errors at all.
Guard::RSpec is running, with RSpec 2!
Running all specs
...
Finished in 0.95467 seconds
3 examples, 0 failures
UPDATE:
I've seen this very similar question Devise: NoMethod Error & user_signed_in and have correctly set up the user model, so that's not the problem.
This is quite confusing to me, hopefully someone out there understands what's happening crossingFingers
Thanks,
xon1c
UPDATE
I fixed it, but stackoverflow won't let me answer my own question in the next 6hrs because of lack of reputation sigh. Will post the solution later.
Ok, I fixed it (close to perfect). Here's what i did:
I reverted git to a working status and began from scratch. This time I did not use the line
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
in my Gemfile, instead I only put
gem 'devise'
and then installed the latest devise gem through
gem install devise
rails generate devise:install
The command installed version 1.4.5, not 1.4.7 as I previously had. Then I installed all the other gems, namely capybara, guard-rspec, factory_girl_rails and launchy. Everything works fine now except these two warnings I'm left with:
Running: spec/requests/sign_ups_spec.rb
DEPRECATION WARNING: :name_prefix was deprecated in the new router syntax. Use :as instead. (called from /Users/xonic/Documents/work/ror.ror.at/config/routes.rb:7)
DEPRECATION WARNING: :name_prefix was deprecated in the new router syntax. Use :as instead. (called from /Users/xonic/Documents/work/ror.ror.at/config/routes.rb:7)
.
Finished in 0.16255 seconds
1 example, 0 failures
Well, as long as everything works, I'm ok with the warnings but if anybody knows how to get rid of them, please let me know.
Thanks.

Latest Rails 3: ActionView::Template::Error (couldn't parse YAML at line 105 column 13)

I have recently encountered into a weird problem or Rails 3, possibly ever since the new rubygems 1.5 update. Basically when I deploy my program to nginx with passenger 3.0.2, I have 500 page immediately and problems like this in my production log:
ActionView::Template::Error (couldn't parse YAML at line 105 column 13):
10: </div>
11: <% end %>
12: <div class="field">
13: <%= f.label :name %> <%= f.text_field :name %>
14: </div>
15: <div class="field">
16: <%= f.label :password %> <%= f.password_field :password %>
app/views/sessions/new.html.erb:13:in `block in _app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'
app/views/sessions/new.html.erb:5:in `_app_views_sessions_new_html_erb___4159562374589718885_19217640_4456777064017176818'
It looks like it's missing something in the environment and so it can't recognize all of my form_for elements. Basically the page is just a simple login page with 2 fields - name and password. This problem also happens for other pages with forms, but only in production environment. In development environment, it's totally working fine. I have upgraded all my gems to the latest version, including rails 3.0.4, which however looks like not quite related to this problem. I also used to deploy the same thing onto the ubuntu on my VMware BEFORE gem 1.5, everything is still fine now, however there's no turning back for the new deployments.
I have deployed this to 2 machines running latest ubuntu, and both machine have such errors. Nginx and passenger are installed with the standard steps. Obviously with this problem the site can never run. Can anyone provide any bug fix for this? Thanks very much if you could!
PS: the login page I wrote is basically from here:
http://railstutorial.org/chapters/sign-in-sign-out#top
I added the following two lines to the config/boot.rb file and the problem was solved.
require 'yaml'
YAML::ENGINE.yamler= 'syck'
I had the same problem. Actually I only needed the first line:
require 'yaml'
No need to set the YAML::Engine specifically.
For a problems with yaml syntax options like 'View/Show invisibles' in TextMate may be very helpful to locate syntax problems, yaml is very sensitive about it.
In my case I just had to replace all tabs with spaces in all locale files.
Also notice, if you don't have nodes with the same name on same level.