Infinite Loop when launching Rails Server - ruby-on-rails

Let me explain my isssue in steps and short example:
Step 1: creating new project:
rails new Project
Step2: creating a controler:
rails generate controller Pages home contact
Step3: launching my server:
rails s
Step4: request the url: localhost:8000/pages/home
An infinite loop of chars starts ! After a while it displays:
js: "/tmp/execjs20120131-2808-a2gs3e.js", line 508: il manque '}' après le corps d'une fonction
js: });
js: ..^
(in /home/Projet/app/assets/javascripts/pages.js.coffee)):
3: <head>
4: <title>ProjetTest2</title>
5: <%= stylesheet_link_tag "application", :media => "all" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
9: <body>
app/views/layouts/application.html.erb:6:in `_app_views_layouts_application_html_erb___588914926_92363960'
Thanks in advance

Does this work for you?
$ rails console
Loading development environment (Rails 3.2.0)
ruby-1.9.2-p290 :001 > ExecJS::Runtimes.autodetect
=> #<ExecJS::ExternalRuntime:0x00000101100048 #name="JavaScriptCore", #command="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc", #runner_path="/Users/mattias/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.3.0/lib/execjs/support/jsc_runner.js", #test_args=nil, #test_match=nil, #encoding=nil, #binary="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc">
ruby-1.9.2-p290 :001 > CoffeeScript.compile(open("app/assets/javascripts/pages.js.coffee").read)
=> "(function() {\n\n\n\n}).call(this);\n"
ruby-1.9.2-p290 :002 >

Finally i found the solution. I just installed nodejs:
sudo apt-get install nodejs
and the following gems:
therubyracer, execjs, mustang

Related

ActionView::Template::Error (defaults.js isn't precompiled)

Recently, I've been working on migrating my Ruby on Rails site, built on passenger, to a different server, and in the process upgrade rails from 2.3.2 to 3.2. I've installed all necessary gems, and I thought configured everything correctly, but when I go to my site, I get a "We're sorry, but something went wrong" message
I checked the production.log and this is the error message I got:
Connecting to database specified by database.yml
Started GET "/login/login" for ip_address at 2013-05-31 20:12:28 -0400
Processing by LoginController#login as HTML
Rendered login/login.html.erb within layouts/homepage (6.9ms)
Completed 500 Internal Server Error in 43ms
ActionView::Template::Error (defaults.js isn't precompiled):
6:<title>test test test</title>
7: <link rel="icon" type="image/png" href="/images/favicon.ico">
8: <link rel="SHORTCUT ICON" href="/images/favicon.ico"/>
9: <%= javascript_include_tag :defaults %>
10: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
11: <script type="text/javascript" >src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
12: <script type="text/javascript" src="/javascripts/jquery-ui->1.8.20.custom.min.js"></script> <%= stylesheet_link_tag 'home_styles', :media => >'Screen' %>
app/views/layouts/homepage.html.erb:9:in
_app_views_layouts_homepage_html_erb__3199970246383683518_43112000'
I'm still pretty new to Rails, so I'm currently at a bit of a loss what to do. Any help would be appreciated!
<%= javascript_include_tag :defaults %>
This tag is from Rails versions pre 3.1. Are you sure this is what you want to do?
In newer applications, this line is typically including the application JavaScript file instead:
<%= javascript_include_tag "application" %>
This is made possible due to the Asset Pipeline which you can learn about by reading The Asset Pipeline Guide.

Rails Error hitting the url on server start: ExecJS::RuntimeError in Spree/home#index

I am trying to setup code on mac os. it worked perfectly on ubuntu. i installed all the gems and when i hit the url after switching on the server i am getting this error. deeply frustrated
Showing /Users/ayruskrishna/code/krizda/app/views/spree/shared/_header.html.erb where line #13 raised:
FATAL ERROR: CodeRange::GetNextAllocationBlock Allocation failed - process out of memory
(in /Users/ayruskrishna/.rvm/gems/ruby-1.9.3-p385/gems/spree_core-1.2.0/app/assets/javascripts/store/checkout.js.coffee)
Extracted source (around line #13):
10: <%= favicon_link_tag '/assets/favicon1.ico' %>
11: <%= stylesheet_link_tag 'store/all', :media => 'screen' %>
12: <%= csrf_meta_tags %>
13: <%= javascript_include_tag 'store/all' %>
14: </head>
15: <body>
16: <div class="wrap">
Trace of template inclusion: app/views/layouts/spree.html.erb
Rails.root: /Users/ayruskrishna/code/krizda
It appears you're using Spree 1.2.0 I'd suggest trying a newer version (v1.2.4 is available in the same stable line). I'd also checkout the Activity Monitor OS X app.. A spree store for me typically uses less than 200MB of RAM.
You could also look at using an alternative web server... http://puma.io/ claims to have a significantly smaller memory footprint than some of the alternatives.

token_error on heroku when I try to load Google API

I am using winston/google_visualr to create nice graphs to visualize statistics in my rails application.
It works fine on my locale system, but if I push it to heroku I get something like a token_error. The result is, that it shows only the Heroku page
We're sorry, but something went wrong.
My head section of application.html.erb looks like this
<head>
<title><%= full_title(yield(:title)) %></title>
<script src='http://www.google.com/jsapi'></script>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
This is the heroku log:
ActionView::Template::Error (Unexpected token name, expected punc (line: 13588, col: 3, pos: 384041)
at expect (/tmp/execjs20121119-2-qx6eku.js:977:40)
Error
at js_error (/tmp/execjs20121119-2-qx6eku.js:505:15)
at new JS_Parse_Error (/tmp/execjs20121119-2-qx6eku.js:497:22)
at token_error (/tmp/execjs20121119-2-qx6eku.js:961:17)
at expect_token (/tmp/execjs20121119-2-qx6eku.js:974:17)
at object_ (/tmp/execjs20121119-2-qx6eku.js:1365:56)
at /tmp/execjs20121119-2-qx6eku.js:1326:51
Completed 500 Internal Server Error in 4980ms
at croak (/tmp/execjs20121119-2-qx6eku.js:954:17)
at maybe_unary (/tmp/execjs20121119-2-qx6eku.js:1425:27)
at expr_ops (/tmp/execjs20121119-2-qx6eku.js:1452:32)
(in /app/app/assets/javascripts/application.js)):
6: <%= stylesheet_link_tag "application", :media => "all" %>
7: <%= javascript_include_tag "application" %>
8: <%= csrf_meta_tags %>
9: <%= render 'layouts/shim' %>
4: <title><%= full_title(yield(:title)) %></title>
5: <script src='http://www.google.com/jsapi'></script>
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__1437494530852335371_34567960'
It looks like that the external script reference may be the reason. Do you have any idea how to implement this?
The demo implementation of the author of the googlevisualr rails extension on heroku works fine. Is there any configuration settings in heroku I need to consider?
Thanks for your help.
It took me a lot of tries but I found the issue.
The error happens if one of the included JS' has syntax errors, i.e. a missing semicolon.
In my Gemfile I didn't add version numbers to my gem '...'.
I was using the gem 'bootstrap-datepicker-rails' in version '0.6.21' for my development environment.
If you push to heroku all your gems will be installed again, with the newest available version. Since version 0.6.28 is the actual version it was installed on heroku. It may have a syntax error and it caused the above issue. So, it had nothing to do with the line
<script src='http://www.google.com/jsapi'></script>
I just corrected the line in my gemfile to the following and all was working then:
gem 'bootstrap-datepicker-rails', '0.6.21'

Rails3.How do I see the errors when I use Compass?

Rails 3. I installed compass and I started to modify application.html.haml to convert it from erb to haml.
So far, it does not work. When I refresh the page the layout do not get rendered. It just render the contents of the controllers' view (which is erb).
It is the first time I use Compass, so probably the code is wrong. My question is, where do I see the errors, warning, etc?
I use Passenger.
Edit:
The code is
!!! 5
%html
%head
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'compiled/print.css', :media => 'print'
/[if IE]
= stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
%title
DaVinci - = yield(:title) || " Inicio"
= stylesheet_link_tag 'compiled/modern'
= javascript_include_tag :defaults
= csrf_meta_tag
%body
#header
.navlist
%ul
%li
= link_to 'Inicio', root_path
%li
= link_to 'Administrar', configuration_index_path
%li
= link_to 'Tareas', tasks_path
%li
= link_to 'Documentos', files_path
%li
= link_to 'Correo', emails_path
= yield(:nav)
#contents
= yield
Can I use Tabs instead of spaces?
Compass errors usually show up when you load the page. If the page loads fine, a second option is to view the HTML source of the page, click on the stylesheet loaded into the page, and see if an error is printed into the stylesheet itself. Finally, you can also precompile your sass sheets by running the command
compass watch .
in your root directory. Compilation errors will be written as the output of this command

How to cache HAML files in /tmp directory?

I'm having an issue with HAML where it is attempting to write to a read-only filesystem (on a Heroku-deployed app).
I can only write to /tmp and /log. How can I configure HAML to write files to the /tmp directory?
Thanks!
Edit:
Output of actual error
Started GET "/" for <ip> at Sun Oct 03 13:19:42 -0700 2010
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.haml within layouts/application (5.6ms)
Completed in 10ms
ActionView::Template::Error (Read-only file system - /disk1/home/slugs/305306_d9977a4_8922/mnt/public/stylesheets/.permissions_check.23729009697080.19743.369932 - Heroku has a read-only filesystem. See http://docs.heroku.com/constraints#read-only-filesystem):
3: %html
4: %head
5: %title= title
6: = stylesheet_link_tag "reset", "application", "grid", :cache => "base"
7: = javascript_include_tag :defaults
8: = csrf_meta_tag
9:
app/views/layouts/application.html.haml:6:in `_app_views_layouts_application_html_haml___661334860_23729045526060_0'
Like Mark commented, I think you mean SASS, not Haml. Here's how to use git commit-hooks to precompile your SASS before deploying to heroku.
EDIT: After full error was posted
Change
= stylesheet_link_tag "reset", "application", "grid", :cache => "base"
to
= stylesheet_link_tag "reset", "application", "grid"
The caching isn't HAML, it's RAILS, and it's doing this on first read.

Resources