1

I have just installed rails 4.2 . I have found this tutorial for making a quick blog: https://www.reinteractive.net/posts/32-ruby-on-rails-3-2-blog-in-15-minutes-step-by-step . However, it uses rails 3.2 . I have done everything that it says up to rake db:migrate and yet, when I run the server, I just get an error page. What has changed since 3.2? what do I now have to do to do the same thing?

error: 'ExecJS::ProgramError in Posts#index' TypeError: Object doesn't support this property or method (in C:/Ruby193/lib/ruby/gems/1.9.1/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee)

EDIT:

On a side note, I can't even follow the official ruby on rails tutorial because when I run the server, after changing the root to root 'welcome#index' , I just get a page not found error.

Are there any tutorials for rails 4.2?

Samuel Bird
  • 47
  • 2
  • 10
  • Note that you have to run rake db:migrate not rails db:migrate, what is the error you are getting? – Ahmad Al-kheat Jan 30 '15 at 16:29
  • sorry that is what I did - Ill correct the post. I will edit the error in as well. – Samuel Bird Jan 30 '15 at 16:31
  • something I noticed - null:false is on the end of t.timestamps in mine but not in the tutorial. Why is this generated automatically? – Samuel Bird Jan 30 '15 at 16:37
  • Oh looks like you are using Windows, this issue definitely has something with the OS. I use mac sorry can't help with this. – Ahmad Al-kheat Jan 30 '15 at 16:43
  • Rails 3 and 4 differ substantially. My advice -- either stick with what your tutorial recommends, or find a different tutorial. [Michael Hartl's book](https://www.railstutorial.org/book) describes a Twitter-like app implementation with Rails 4. And yes, Rails development on Windows is tedious, so this book recommends a cloud environment, I personally recommend using Ubuntu flavors (Xubuntu, or maybe Linux Mint), possibly in a virtual machine. – D-side Jan 30 '15 at 16:52
  • I am trying to get hold of a linux comp at the moment - this will have to do for the time being. It is too slow to run a VM. – Samuel Bird Jan 30 '15 at 16:54
  • How can I backdate my rails? Do I have to do a full reinstall? How with gems? – Samuel Bird Jan 30 '15 at 16:54
  • Sure thing. `Gemfile` specifies versions of gems your app needs (these should be in the tutorial). Write specific requirements there, then run `bundle install` and Rails should get downgraded. – D-side Jan 30 '15 at 16:57

3 Answers3

4

I had exactly the same ExecJS::ProgramError on Windows. The only solution that really helped was provided by KeithP here: Rails-4, ExecJS::ProgramError in Pages#welcome, i.e.,

Rollback to gem 'coffee-script-source', '1.8.0'.

Community
  • 1
  • 1
dd_hk
  • 110
  • 7
4

There's some info here: ExecJS::RuntimeError in Users#index (RoR)

What I found when I looked into this problem was that in CoffeeScript there's a checkin here that I think broke things for Windows (under certain versions of the cscript runtime): https://github.com/jashkenas/coffeescript/blob/28c07d30cbd2add7ee762c7d532b2c9c972e441a/lib/coffee-script/parser.js

On line 563 it's doing an Object create(lexer) which fails with the error ActionView::Template::Error (TypeError: Object doesn't support this property or method.

Rolling back to CoffeeScript 1.8.0 (before this change) works around this problem. As others have stated in this answer and elsewhere, using a different runtime will workaround this problem too.

To roll back to CoffeeScript 1.8.0 add this to your gemfile:

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

And run these commands:

gem update 'coffee-script-source'
bundle update 'coffee-script-source'

Restart your server and it should be working.

Community
  • 1
  • 1
Jonathan Yee
  • 1,957
  • 2
  • 19
  • 21
1

This should solve your problem:
Add gem 'therubyracer', '~> 0.12.1' into your gemfile (or uncomment it - should be already there...)
Then run bundle install

Hope this helps.

Tom
  • 520
  • 2
  • 17
  • there was `gem 'therubyracer', platforms: :ruby` which I uncommented. I then miggrated db, ran the server and there is the same problem. Should I add it like you said? with the 0.12.1? – Samuel Bird Jan 30 '15 at 17:49
  • and you ran bundle install too, right? You can try the code as i suggested as well, yes. But always bundle install afterwards – Tom Jan 30 '15 at 17:54
  • Now I am getting lots of errors when using bundle install (with 0.12.1). I tried removing the s from https in the gemfile source, which worked last time, but there are still errors. I will post the errors in my original question. – Samuel Bird Jan 30 '15 at 17:54
  • 1
    ok, then i guess you have the same problem as described and solved here: http://stackoverflow.com/questions/12520456/execjsruntimeerror-on-windows-trying-to-follow-rubytutorial – Tom Jan 30 '15 at 17:57
  • I tried it with the https, and it says that it 'failed to path specified', and is asking me to install libv8 before continuing. This is what happened before, and when I install it they just keep asking me to install more. – Samuel Bird Jan 30 '15 at 17:59
  • I tried that other guys fix - it didn't work. I will try battling with the bundle install, and installing them individually as it says. – Samuel Bird Jan 30 '15 at 18:04
  • I just tried to install libv8 as bundle install said, and there are still errors with failing to build gem native extension, even when installing that gem alone. – Samuel Bird Jan 30 '15 at 18:11
  • try to uncomment as much gems as possible (to narrow the problem down) and fix your environment first. Sounds like there is something wrong in general. if the bundle comment gives you errors google those and fix it step by step. From error message to error message. Then come back to your actual problem... – Tom Jan 30 '15 at 18:17
  • All un-commented apart from unicorn, bcrypt, and capistrano. Should I do these? They seem irrelevant. – Samuel Bird Jan 30 '15 at 18:19
  • yes start with those - unless you are sure your unicorn setup is working – Tom Jan 30 '15 at 18:28