I came into work today to find that my project is throwing a syntax error for some reason, and I can't find a single thing about this error.
When using the stylesheet_link_tag or javascript_include_tag helpers, I receive SyntaxError: [stdin]:1:1: missing ///.
Some things I have noted are:
If the links dont lead to a valid file, it compiles just fine.
Even if the files are empty the error is still thrown so the syntax error is definitely in the erb, even though I havent changed my application.html.erb since adding the link for the fonts.
EDIT:
After rewriting the layout in haml, the error persists, so I suspect it is not in the erb but in the ruby functions for linking, although I don't know what could have changed.
I just noticed the "ExecJs::RuntimeError", which is interesting because I commented out the javascript link so i could deal with one at a time.
Any help is appreciated. I feel like I'm missing somethinng very simple here, but i cant find it for the life of me.
If you want to see any of my code let me know, I wasnt sure what would be relevant other than this error page:
EDIT 2:
Here's my "appllication.html.erb":
<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>{Site Name}</title>
<%= csrf_meta_tags %>
<link href="https://fonts.googleapis.com/css?family=Lato:400,300|Raleway|Tangerine:700" rel="stylesheet">
<%= stylesheet_link_tag "application.css", media: "all", "data-turbolinks-track": "reload" %>
<%#<%= javascript_include_tag "application", 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
This error was caused by a compilation error somewhere in the rails asset pipeline. This specific instance was caused by a rogue TypeScript file in app/assets/javascripts after I had removed typescript-rails from my Gemfile.
Thanks to #dstarh I was able to find the error.
I'll leave this here since I couldn't find any information on this error anywhere. Hopefully it can help someone else.
Related
First of all, I open the Windows command prompt with Ruby and Rails via the shortcut provided by RailsInstaller. First of all, I create a new Ruby on Rails application using the following command. I call it "curso"
rails new curso
After that, I navigate to the project folder C:\Sites\pruebaand start the WEBrick server, like this:
rails s
I go to localhost:3000and the test page runs perfectly.
After that, I import the project in NetBeans. Then, I open the command prompt and create a new controller, like this:
rails g controller miprueba index
I check the file Views/layouts/application.html.erb, which was generated by Rails and it looks like this:
<!DOCTYPE html>
<html>
<head>
<title>Prueba</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= yield %>
</body>
</html>
NetBeans shows me an error on line 7. It says Unexpected ':'. The same error happens in line 8.
If I try running the application, in localhost:3000/miprueba/index, I get an error page titled "Action Controller: Exception caught". It says this:
ExecJS::ProgramError in Miprueba#index
Showing C:/Sites/prueba/app/views/layouts/application.html.erb where line #7 raised:
TypeError: El objeto no acepta esta propiedad o método
The last line roughly means "The object doesn't accept this value or method".
If I delete lines 7 and 8 the application runs just fine, but I'm curious about why are those two lines generated and why do they fail.
The first error being thrown by NetBeans is likely a red herring. The error concerning the unexpected ':' is related to the use of colon-hash syntax on an escaped symbol in an implicit hash. ERB isn't technically ruby, so NetBeans is probably getting confused.
The real error is related to running ruby on rails on Windows. The error is actually being thrown by a javascript runtime, not rails. The short answer is that you can install NodeJS to replace your existing runtime with one that works well with Rails. Or you can follow the instructions here:
execjsruntimeerror-on-windows
Rails on Windows is tough. Good luck!
According to the bootstrap docs
adding the following to your <head> makes your site responsive
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="assets/css/bootstrap-responsive.css" rel="stylesheet">
In rails and the asset pipeline you declare your css file in application.css so the last line above is not required.
Im using the bootstrap-sass gem and the above line is achieved this line of code in the application.css file
#include "bootstrap-responsive";
It works!
But unfortunately this makes every view responsive.
I have a number of views such as my backbone app that I dont want to be responsive.
I thought about declaring the <meta viewport...> tag into a layout file that is only used for the those parts of my site that require responsive behavior.
This doesn't seem to work and despite some views not declaring this meta tag via their layout, they still become responsive.
Since I cant granularly control which css files get loaded in the asset pipeline I'm a bit stumped how to turn off and on this responsive behavior.
How do i achieve this?
Check out This link for some good info. It can be overwhelming, know, you don't have to do ALL of that... The key is: if you remove require tree (which will not add all files in directory) you need to manually add them in config/environments/production.rb with:
config.assets.precompile += %w( application-all.css application-print.css application-ie.css )
Then you can use stylesheet_link_tags with no issues...
To make it more flexible I add this to my application head:
<%= yield :head if content_for?(:head) %>
and then all my views use:
<% content_for(:head) do %>
<%= stylesheet_link_tag "#{params[:controller]}.#{params[:action]}" %>
<%= javascript_include_tag "#{params[:controller]}.#{params[:action]}" %>
<% end %>
I've set up application.html.erb to link to a stylesheet using the following code
<%= stylesheet_link_tag 'stylesheets/style', :media => 'screen' %>
However when I load the localhost in the browser window it prints this code
<link href="/assets/stylesheets/style.css" media="screen" rel="stylesheet" type="text/css" />
when I view the file directly I'm shown this error
Routing Error
No route matches [GET] "/assets/stylesheets/style.css"
I've read on some other questions that rails by default looks in public/stylesheets so I'm not sure why it's looking in assets?
I also tried to move the css file to the assets directory just to see if it would work however, it still doesn't work and gives the same routing error.
Been stuck on this for a couple of days and it's really doing my head in so appreciate any help you can give me.
Thanks in advance
Rails 3 comes with a new assets management which is actually one of the biggest pluses.
A guide on how it works is here
So if you have the application.css file in your assets/stylesheets you can simply drop the style.css in your assets/stylesheets directory renaming it in style.css.scss
In your view just leave:
<%= stylesheet_link_tag "application", media: 'screen' %>
Through sprockets the Rails app will load it.
I've updated http://tetalab.org/ with RefineryCMS 1.0.8, and now, our stylesheets and javascripts are outputted as safe html, breaking anything on the site.
Exemple of code outputting safe html:
<%= javascript_include_tag 'modernizr-min' %>
Code found in html source:
<script src="/javascripts/modernizr-min.js" type="text/javascript"></script>
Could someone provide some tips about this issue?
This is likely because you're using refinerycms-theming plugin.
This plugin does bad things and is not recommended
I think if you removed that the problem would go away :)
I'm attempting to create a facebook app and went through the book http://pragprog.com/titles/mmfacer/developing-facebook-platform-applications-with-rails. Everything works fine on my development machine when I have my canvas render method set as fbml. But, for various reasons I want to build an app with an iframe. When I set my app to use an iframe I am unable to connect to my development machine. I went through a lot of different articles about creating an iframe app, but none seem to work. That includes
http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel
http://wiki.developers.facebook.com/index.php/XFBML
and any other site found googling any combination of facebook, iframe, rails and others.
I have the xd_receiver.htm file in my public directory and my layout looks like
<!doctype html public “-//w3c//dtd xhtml 1.0 strict//en” “http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xmlns:fb=”http://www.facebook.com/2008/fbml”>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag "jquery-ui-1.7.1.custom.css", "styles" %>
<%= javascript_include_tag "jquery-1.3.2.min.js", "application" %>
</head>
<body>
<%= yield %>
<script src="http://static.ak.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<script type="text/javascript">
FB_RequireFeatures(["XFBML"], function(){
FB.Facebook.init("my api key", "xd_receiver.htm"); });
</script>
</body>
</html>
My question is, what am I missing that is preventing facebook from connecting to my rails development machine when I set the canvas render method to iframe? Since my development log does not show any attempts of a connection, I'm guessing that it has something to do with the cross domain stuff, but I can't find a good answer about it anywhere.
If you place that file under /public, its important to note that the ERB contained within the template will not get parsed as you expected. I'm not too familiar with the plugin you are trying to use but have used the Facebooker gem (http://facebooker.rubyforge.org/) which provides a tidy way to interact with the Facebook REST API.
I strongly suggest using Facebooker from the beginning.
It'll save you a lot of time.
/xd_receiver
there are facebooker methods for this sort of thing check this out
http://blog.yangtheman.com/2009/08/23/how-to-integrate-facebook-connect-with-a-rails-app/