1

I am new to ruby on rails. I finally succeeded installing rails on ubuntu 11 and created an app with "rails new myapp".

But while generating a model with "bundle exec rails generate model Comment user:string user_comment:text" i am getting the following error:

I am clueless for what might have went wrong.

/home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.9/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.9/lib/execjs.rb:5:in `'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/execjs-1.2.9/lib/execjs.rb:4:in `'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290@global/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
    from /home/pratuat/Documents/rails/railsdemo/config/application.rb:7:in `'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands.rb:21:in `require'
    from /home/pratuat/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.3/lib/rails/commands.rb:21:in `'
    from script/rails:6:in `require'
    from script/rails:6:in `'
1

1 Answer 1

4

https://github.com/sstephenson/execjs

You need to choose from that list of runtimes. The easiest I've found is therubyracer. Add this to your Gemfile, then do a bundle install.

gem "therubyracer"

After that your model generator should work.

Sign up to request clarification or add additional context in comments.

2 Comments

also i noticed you either need node.js or gem 'execjs' installed on ubuntu.
if you install node.js you dont need to do any of this for new applications as it gets picked up by rails as your javascript runtime.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.