How test a Rails app in a browser - ruby-on-rails

I used Fedora 21 in VirtualBox to create a rails app.
I have installed Ruby, Rails, rubygem, and bundle ($ bundle install) for my rails app.
However, when I go to http://localhost:3000/, there is an error...
When I run this command :
$ rails server
There is an error : Could not find a Javascript runtime
Thank you for your help.

run bundle exec rails server if it still there try this
yum -y install nodejs
or look at this

Related

Ruby on Rails ufinished

enter image description here
I have been trying execute the command --> rails new weblog in Terminal from Linux Mint after install Ruby however the application cannot be complete with the same error message, below:
Either bundle install or rake exec bundle install
What I can understand from the logs referenced in the question is that you are not executing bundle install command inside the project directory i.e. weblog. So first cd to weblog.
cd weblog
bundle install
I hope this helps!.

Rails app is deployed and on, but bundle not seeing rails

I use Rails 4 in my app and am deploying it using Ansible&Capistrano.
As an Ansible template I use playbook pretty similar to this one - https://github.com/JohnnyR1co/fashcards/blob/master/config/provision/playbook.yml
It installs ruby as well as anything else and After cap production deploy I am able to see app on (I can load some non-db related pages).
But when I try to run something like RAILS_ENV=production rails c from the current folder I get
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: apt-get install <selected package>
Why is this so? App is up and running, so rails seem to be fine.
Also when I try to run bundle install I get an error that nokogiri is not installed, despite I installed it manually after deploy. What could be the reason here?
I believe problem could be in playbook.ymlfile. Ruby installation is done there and I am not sure how correct is it.
This will do
bundle exec rails c production

'rails c' doesn't work, but 'bundle exec rails console' does

I'm setting up the staging and production server on Ubuntu, deploy with Capistrano. Both server has pretty much the same setup. But for for some reason. I can access console on production server with rails c produciton. But when I try to access console on staging server using rails c staging
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: sudo apt-get install <selected package>
The only way to access console on my staging server is to do
bundle exec rails console staging
On staging
the rvm seems to be correct, I can see the ruby version I'm using.
the gemset that the application use is there.
the application is running fine. Just can't access console with 'rails c'
But for some reason, I can't access console with rails c. Any idea how to solve this issue?
I guess you didn't install rails globally. First, check your rails version you are currently using by bundle exec rails -v. Then, install rails globally by gem install rails -v <version>. This should solve your issue.
Run bundle install only makes rails available inside bundler. In most cases, this should be enough, because bundler helps prevent headaches of version conflicts.
A couple of questions to understand better the situation...
Have you tried running bundle install for the current ruby version set on rvm for that application on that server?
Have you updated the gems for another application/branch? sometimes that happens because the rails c command uses the latest gems available and bundle exec... locates and uses the gems tied to the Gemfile.lock.
The application should run fine because it uses the gems that the Gemfile.lock has listed.

How to clone and run another user's Rails app

I'm attempting to do something I've never done before: clone another user's (codeforamerica) repository and run it locally on my computer with the intention of making my own changes to it.
I've managed to fork it to my own repositories, and cloned it:
git clone https://github.com/martynbiz/human_services_finder.git
...but when I do the following straight out the box:
cd human_services_finder
rails s
...it tell me:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
...however, if I go into one of my own apps and run rails s it runs the server OK. Is there something missing I need to run this as a Rails app? Sorry, bit of a beginner with this one. Thanks
Below are the setups to run Ruby on Rails application on your system.
Make sure Ruby is installed on your system. Fire command prompt and run command:
ruby -v
Make sure Rails is installed
rails -v
If you see Ruby and Rails version then you are good to start, other wise Setup Ruby On Rails on Ubuntu
Once done, Now
Clone respected git repository
git clone https://github.com/martynbiz/human_services_finder.git
Install all dependencies
bundle install
Create db and migrate schema
rake db:create
rake db:migrate
Now run your application
rails s
You need to install all the dependencies (Gems). This should be possible by running
bundle install
from the applciations directory.
If you are not using RVM yet I would strongly recommend doing so.

Rails3 Console Command not working

I was able to run rails console in a rails directory fine, however I ran into a problem running rails console --sandbox where I was getting an error like this:
no such file to load -- readline (LoadError)
After running this command: sudo apt-get install libncurses5-dev libreadline5-dev
(found here http://pranshuarya.com/jaal/Development/rails-3-error-require-no-such-file-to-load-readline-loaderror.html)
I now receive the following error when running either rails console or rails console --sandbox:
Could not find mail-2.2.16 in any of the sources
I am running Ubuntu 10.10, Ruby 1.9.2 and Rails 3
Any ideas?
I think that you could be having some gem in your gemfile but you did not run bundle install to install it. Please check that out.

Resources