install ruby on rails on windows - ruby-on-rails

I need to run an application built in ruby on rails. I have installed ruby 1.9.2, rails 3.2.1, gem 1.8.15, Netbeans 6.8, glassfish v3, jdk6u30 and mysql but still, I can't get it run.
How do I install ruby on rails on WindowsXP?

I have to code on Windows at work and deploy to Linux and this is what I use
Ruby installer
Ruby Dev Kit
Install Rubygems
Open a Ruby command prompt for the next steps
gem install bundler
bundle install mysql
bundle install rails
Go to the directory you want to house your rails apps (e.g. cd \rails_source)
rails new (inserting the app name you want)
Once that is done, cd into the directory
Edit Gemfile to ask for gem 'mysql'
cd Config
edit Database.yaml to look for mysql db
cd ..
create a db for your mysql instance called _development
Go back to rails command line
bundle exec rails g scaffold (like blog_entry)
bundle exec rake db:migrate
bundle exec rake routes
Look for your desired route in the output
bundle exec rails s
Open a browser
Go to http://localhot:3000/
You should see a plain app
You can also check out Rails for Zombies which is a visual tutorial. It is not windows oriented but it helps fill in the gaps

I think its a quite simple to install ROR with mysql database on windows.
Follow the below instruction
Install Mysql Server 5.6 from [http://dev.mysql.com/downloads/mysql/] , use 32bit for XP and 64Bit for W7.
Go to mysql/bin folder under Program Files and copy and set the path in environment variable.Open command propmt and type mysql in order to check if mysql is installed correctly.
If still problem with Mysql, open run and type services.msc and check for MySQL service is started or not if not start manually.
Download ruby2.0.0, devkit 64-32 from http://rubyinstaller.org/downloads/
Download mysql connector from [http://dev.mysql.com/downloads/connector/c/] and make sure the version should be "(mysql-connector-c-noinstall-6.0.2-win32.zip)", you will find in "Looking for previous GA versions?".
Install ruby in C folder and select add path to executable while installing in first/second prompt.
Create folder devkit and extract devkit into it.
Extract mysql connector in C folder.
Open command Prompt and type ruby -v in order to check if ruby is installed, if not check ruby/bin path have to be added in environment variable.
Go to devkit folder, where you have extracted devkit, open command prompt and type ruby dk.rb init and then ruby dk.rb install.
Now we go through test, follow the instruction is given in test installation section in https://github.com/oneclick/rubyinstaller/wiki/Development-Kit and check with command starts with gem and ruby.
Create directory called dev and go inside it and type command gem install rails.
rails new app -d mysql2
Run command "bundle config build.mysql2 --no-ri --no-rdoc -- --with-mysql-dir=c:\mysql-connector[select what folder name is there for mysql connector]".
bundle install.
If still problem is exist, delete app folder and repeat command rails new app -d mysql2 again.
Go to app folder and use command rails server to start services. Check in browser with localhost:3000.
To create DB, use rake db:create in app folder.
Hope it helps.

Related

Using rvm bundle install doesn't install rails

I'm freshly using rvm for running a legacy project.
I installed rvm fine. Running which ruby gives the correct rvm version:
/Users/Mahmoud/.rvm/rubies/ruby-2.5.5/bin/ruby
Then running which bundle, also indicates that bundle is using the correct rvm version:
/Users/Mahmoud/.rvm/rubies/ruby-2.5.5/bin/ruby
Now to get my project running, I run bundle install. It's important to stress on the fact that in my Gemfile I have
gem 'rails', '5.0.7'
Running rails s after those steps, gives:
Rails is not currently installed on this system. To get the latest version, simply type:
Running which rails gives:
/usr/bin/rails
implying that the system version and not the rvm version is being used.
echo $PATH shows:
/Users/Mahmoud/.rvm/gems/ruby-2.5.5/bin:/Users/Mahmoud/.rvm/gems/ruby-2.5.5#global/bin:/Users/Mahmoud/.rvm/rubies/ruby-2.5.5/bin:/Users/Mahmoud/.rvm/bin:/Users/Mahmoud/.pyenv/versions/3.7.2/bin:/usr/local/bin:/Users/Mahmoud/.pyenv/bin:/usr/local/opt/openssl#3/bin:/usr/local/opt/openssl#3/bin:/usr/local/opt/libxml2/bin:/usr/local/opt/mysql#5.7/bin:/usr/local/opt/mysql#5.7/bin:/usr/local/opt/mysql#5.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin:/Users/Mahmoud/.ebcli-virtual-env/executables:/usr/local/mysql/bin
My question is, why hasn't rails been installed when I used bundle install? And why is which rails refering to my system and not my rbenv path?
I'll bet your RVM isn't set up correctly and /usr/bin/ appears in your PATH before RVM's bin directory. Run echo $PATH to confirm.
If so, back up your dotfiles for safety and run rvm get head --auto and it should put your PATH right. Logout and log back in or source your dotfiles (source ~/.bash_profile or whatever) and try again.

'bundle is not installed' error

I am not good with devops. I had created a user called deploy. Previously I could ssh into my server then
su deploy
and run
RAILS_ENV=production bundle exec rails c
.
Some days ago, I completely forgot that I had a user called deploy. Being the root user, I installed ruby using rvm. RVM was already installed.
Now I remember that I have a user called deploy. I ran su deploy then ran
RAILS_ENV=production bundle exec rails c
I got the following error
The program 'bundle' is currently not installed. To run 'bundle'
please ask your administrator to install the package 'ruby-bundler'
Before I had installed ruby in super admin env I could run bundle in the deploy user env.
Is there a way to fix this?
PS: My capistrano deployment script is running without any problem even if it is being deployed by the "deploy" user
The problem is that when you ssh into the directory, at the directory, no .ruby-version file exists, so it use the default ruby version(run which ruby to see the exactly path), not the rvm ruby version, so it can't find the installed gems like bundler.
It's a environment problem.The capistrano deployment is working because you have assign ruby version in your deploy.rb like
set :rvm_ruby_version, 'ruby-2.2.2#zhitaotao'
so it can find correct ruby version, then find installed gems for the version.
The solution is add a file called .ruby-version, set the content to something like ruby-2.3.1.
If this not works, i suggest to reinstall ruby, bundler, and run bundle install for deploy user. We need to make sure that at the production directory, the ruby version is matched with the ruby version assigned in the deploy.rb.

copies a rails app to a new computer: rails command not found

I have just set up ruby and rails on a freshly installed freeBSD. It works great. I can do rails new blabla mv into blabla and do rails s and it just works.
I had an up and running rails app on another computer. I copied the repertory that contained the app to the new computer running freeBSD. However, when I mv into that repertory of the rails app and to rails server I get -bash: rails: command not found
I have tried creating a new app with the same name and let rails create all the repertories and then copy the files of the existing rails app therein but no success.
I can run rails -v and rails s from within any repertory and get correct answer, but when I move into that specific repertory I get that command not found.
You're probably using a ruby version manager I suspect (rbenv/rvm)? Check the ruby version in your Gemfile (top of the file). It probably isn't the same as the ruby version you have installed. If you're using one of the above mentioned version managers than install the correct ruby for your rails project. After that you can do a gem install bundler in the project directory and after run bundle install which will install rails and all dependencies.
Which version you are using? It happens with earlier versions. Try updating your gems and bundler. And try again. Hope it helps.
Did you try running bin/rails s? I think tha you need run bundle install too.

Rails Server is not starting on Windows 10

I am using windows 10. I install Rails and other supporting software via railsinstaller.org website.
Now I go on CMD and writing command rails server but Rails server not starting work. when I open link in firefox http://localhost:3000
Following is snapshot of output when I write rails s in cmd. I have Rails 4.2.5.1 in my PC and using Windows 10
The problem my be caused due to following (Unable to Install gems)
if you are using latest version of ruby installer to install ruby then there are problem for installing nokogiri and ulifier or other gem which needs to compailing in your pc. so you needs to install devkit first. For this please do following:
The download is a self-extracting archive. When you execute the file, it’ll ask you for a destination for the files. Enter a path that has no spaces in it. We recommend something simple, like C:\RubyDevKit\. Click Extract and wait until the process is finished.
Download from here
Next, you need to initialize the DevKit and bind it to your Ruby installation. Open your favorite command line tool and navigate to the folder you extracted the DevKit into.
cd C:\RubyDevKit
Auto-detect Ruby installations and add them to a configuration file for the next step.
ruby dk.rb init
Install the DevKit, binding it to your Ruby installation.
ruby dk.rb install
Now run bundle install
If still problem persist downgrade your ruby or install linux distro.
You need to change your directory to the app root folder.For Example if your app name is 'myapp', then type cd myapp and run rails server with rails s.
Check if the bin/rails file is in place. If not, generate a new sample app, then copy the bin folder to it.
simply add gem "tzinfo-data" to your Gemfile and run bundle install and you are good to goenter image description here

Beginning Ruby on Rails in Linux Mint

This may sound very basic to many of you. I have just started a Ruby on Rails tutorial in Linux. I'm very new to the Linux OS. I have installed a rvm. But I am unable to install Rails. It's saying "cant load such file --zlib". And I can see two source files for Ruby. Not sure if I have two Ruby installed.
Just take a note that you have selected the correct build system:
"Tools -> Build System -> Ruby"
Then press CTRL+B.
This should work.
You can execute .rb file in sublime using ctrl + b.
It seems you are a bit confused about how Ruby on Rails work.
Sumblime can run your ruby code but not on Rails stack.
My suggestion it's to work always with an open terminal on the directory of your rails application.
Let's assume you created a new rails project as
rails new helloWorld
The rails generetor will create a subfolder helloWorld.This will be your working directory in the terminal.
So you have to do:
cd helloWorld
and then
rails s
It will run your rails application on an embedded server on localhost:3000 by default.
What method did you use to install ruby?
If you compiled from source you may need to do
sudo apt-get install libssl-dev
And then recompile ruby
Otherwise, you may not have the most recent version of Rubygems
Try:
go to https://github.com/rubygems/rubygems/releases/tag/v2.2.3
download rubygems-update-2.2.3.gem
call the directory where the file was dl'ed, then
gem install rubygems-update-2.2.3.gem
update_rubygems --no-ri --no-rdoc
rubygems --version #Should show 2.2.3
gem install rails

Resources