10

I am trying to add login-logout functionality to my rails app. For that I added bcrypt gem for password encryption and also access controller. Now when I run it locally, I get an error message. My app was running fine before adding the above functionality.

Error Message:

TypeError: Object doesn't support this property or method
(in C:/DevKit/lib/ruby/gems/1.9.1/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)

Extracted source (around line #8):

<head>
  <title>PostApp</title>
  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track'=>true %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track'=>true %>  ----> Line 8

      <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
      <%= csrf_meta_tags %>

Gemfile:

source 'http://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
group :development do
  gem 'sqlite3' 
end
group :production do
  gem 'pg'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'

I don't know what kind of type error I am getting. Any idea what might be going on?

Thanks, Chuchoo

Tom Lord
  • 27,404
  • 4
  • 50
  • 77
Chuchoo
  • 823
  • 2
  • 17
  • 36
  • @Nikolay Kostov, sorry I think my edit overrode yours.. – Chuchoo Jan 30 '15 at 18:38
  • possible duplicate of [What do I need to do to get the blog to work in rails 4.2?](http://stackoverflow.com/questions/28240245/what-do-i-need-to-do-to-get-the-blog-to-work-in-rails-4-2) – irowe Sep 08 '15 at 21:38
  • I hope this can help you ! [http://stackoverflow.com/questions/28421547/rails-execjsprogramerror-in-pageshome](http://stackoverflow.com/questions/28421547/rails-execjsprogramerror-in-pageshome) – Rokni May 10 '16 at 07:51

8 Answers8

42

There is a problem with coffee-script-source 1.9.0 running on windows.

It seems you have to add this to your gemfile:

gem 'coffee-script-source', '1.8.0'

then do

bundle update coffee-script-source
KeithP
  • 1,803
  • 1
  • 16
  • 23
  • Thanks @KeithP, how do you know my windows is running coffee-script-source 1.9.0? Its not even mentioned in the gem file. – Chuchoo Feb 08 '15 at 14:26
  • I updated my app with coffee-script-source, 1.8.0 but still getting same error. Didn't seem to do anything. Still looking at it will update you.. – Chuchoo Feb 08 '15 at 14:36
  • Just commenting this line in the above code segment solved my problem. <%=j avascript_include_tag 'application', 'data-turbolinks-track'=>true %> Not sure if this is a preferred solution but certainly helped me to move forward. – Chuchoo Feb 17 '15 at 20:40
  • 2
    Installing x86 nodejs runtime helped me without changing gemfile. – Ondrej Galbavý Mar 15 '15 at 19:56
  • 1
    Just don't forget to restart the server after the updates have been done. – Krycke Feb 17 '16 at 08:53
2

Install node.js x86 version (Not x64 version even if have 64-bit computer) You can download it from https://nodejs.org/en/download/

All the other answers are not neccesary.

  • No need for "coffee-script-source" or "execjs"
  • No need to modify even execjs files
  • No need to add path for Node.js as x86 adds it automatically

After installing node.js, you need to restart the rails server AND the CMD shell where it is running, to update the path it will see.

wallewek
  • 3
  • 3
Nitish Kumar
  • 409
  • 4
  • 4
2

I was having this same issue and I fixed it by adding the following code to config\initializer\assets.rb

Rails.application.config.assets.precompile += %w( application.css )
summerdaiz
  • 77
  • 1
  • 9
0

Just commenting this line in the above code segment solved my problem.

<%=j avascript_include_tag 'application', 'data-turbolinks-track'=>true %> 

Not sure if this is a preferred solution but certainly helped me move forward.

Chuchoo
  • 823
  • 2
  • 17
  • 36
-2

@Chuchoo, commenting the <%=javascript_include_tag 'application', 'data-turbolinks-track'=>true %> solves the issue.

For the many newbies out there, more details on how to get to the solution.

Go to your app directory and access the application.html.erb file from your_app>app>views>layouts>application.html.erb and comment the javascript on line 6.

<!--%= javascript_include_tag 'application', 'data-turbolinks-track' => true %-->

Refresh your page and you are good to go.

-2

uncomment (app/assets/javascripts/application.js)

//=  require jquery
//=  require jquery_ujs
//=  require turbolinks
//=  require_tree .
Laurel
  • 5,965
  • 14
  • 31
  • 57
-3

Go to your app directory and then open application.html.erb file inside app/views/layouts and comment these two lines (5th and 6th)like this:

 <!-- %= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> -->

refresh your webpage ,and Your problem is solved!

-5

Hello I had the same problem and you can make this : https://www.youtube.com/watch?v=N5i94L17KPo It works now for me.

myzen2
  • 1
  • 1