Issues starting a rails server - ruby-on-rails

I am working on an application that makes use of Ruby on Rails. There are 5 of us in the group and so we are using GitHub. I have rails setup on my computer and am able to create my own projects and databases from scratch but when I clone our existing project from GitHub and try to start the server I run into all sorts of issues.
I should mention that I am working on a Windows 7 machine and the initial project was created on a Linux machine. I imagine this could be the source of some of the issues.
Bottom line, when I am in the necessary folder and I type rails s I get a lengthy error message that starts with:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32
/lib/mysql2/client.rb:44:in `connect': Access denied for user 'root'#'localhost'
(using password: NO) (Mysql2::Error)
There is a ton more information that I could provide but I'm not sure what all is needed to help solve this issue. I am a beginner (both with StackOverflow and RoR) so I apologize for not being more clear and concise.
Thanks in advance.
Additional Information:
mysql: Ver 14.14 Distrib 5.5.30, for Win 64 (x86)
ruby: Ver 1.9.3p125
rails: Ver 3.2.0
mysql gem: Ver 2.9.1
mysql2 gem: Ver 0.3.11

It seems that your rails app is trying to log into MySQL with the wrong credentials.
Update the file config/databases.yml to set the rights credentials.
Note that this file should not be checked into version control since it is different for each member of the team.

Related

How to install postgresql in already created Rails app on Mac?

I'm new here and just installed ruby on rails on my mach using this tutorial.
I created a project folder and added an app to it.
Now I want to use postgresql, how do I install that in this created app... that is something I can't figure out.
I think I need to install Postgresql first.
Is the best way to do it form command line like this:
brew install postgresql
or
go to their website and download/install?
Remember I'm totally new to this so help is appreciated a lot
Thanks
EDIT: So I downloaded postgresql and installed it and I downloaded and installed pgadmin.
What's next is probably I have to create a database? and then somehow find a way to connect it with the application created in the workspace for ruby?
Postgres.app is great and has become the go-to for many Mac developers.
https://postgresapp.com/

I have a complete ruby project on my system but how do I run it?

I have a complete ruby project on my system that I downloaded from github.com and I want to run it on my Windows machine.
I have already installed Ruby and Rails on my system, but I have no idea how to run this project. The directory of this project is something like:
C:\Users\{username}\Desktop\BitcoinFundi\BitcoinFundi
How would I run this project on my system?
To run your Ruby on Rails application, use the following command:
rails server
This will start the server and you will be able to access the application in your browser at http://localhost:3000. Port 3000 is default and you can change it in the application settings.
To run a Ruby script use:
ruby name_of_script.rb
You should check out various resources and tutorials on getting started with rails.
As you say in your comment this is your first experience with Ruby on Rails, I think you should follow through chapter 1 and 2 (at least) of Ruby on Rails Tutorial. After that you should have a better understanding of how you start up a rails app and configure the DB. You also need a bunch of other libraries and software such as mysql from the sounds of it.
You should also read Getting Started with Rails. Section 4 covers how to start the default rails server.
Here is a guide on setting up a Rails environment for Windows, which is one of many guides, that shows you some of the needed steps to get a fully working environment.

How do I set up an old Ruby on Rails project on a new server?

I'm not a RoR programmer myself, but a good client of ours has sent a project their previous web team built and I need to get it up and running on their server.
The server uses cPanel and Ruby on Rails is already installed. I've created a project via the cPanel wizard and located the file tree via SSH.
Using SSH, I've tried to replace this file tree with the project I've been sent, but when I hit 'run' in cPanel, the application doesn't actually start (although the success message would indicate that it has).
If I leave the original cPanel-created application in place, I can run/stop no problem and the web interface at :12001 opens up just fine.
I assume there are either conflicts with RoR versions that I need to resolve, or there's simply more to it than just replacing the file tree? Again I'm not a RoR programmer and I'm having a hard time finding a migration guide that tells me anything other than "set up in cPanel and replace the files".
I'd very much appreciate either some genuinely useful links to RoR application setup/migration guides (ideally for cPanel) or a step-by-step answer please.
First, forget Cpanel for now. Try in one environment where you can control everything.
Try to know better the rails version used and the associated gem19s or plugin if from 2.x days. The ruby version is important too, only then you can start defining a plan.
I'm afraid you won't get a step-by-step answer, but I'm sure you can be pointed in the right direction by providing the requested information.
Simple questions: Do you have a Gemfile file at the top at your project? Do you have any plugins (stuff in vendor/plugins)?
Update:
With the Gemfile provided here are the required steps:
Install ruby (if you haven't install it using rvm. The version 1.9.3-x should be the safest.
Install rubygems
Install bundler
Go the project dir and run bundle install
run rake db:migrate (assure you have the database setup acording to config/database.yml
run rails s and check the logs and see if the server is up.
If after installing bundler, you don't have the bundle command in your path, you need to add this your .bash_profile:
PATH=$PATH:$HOME/.local/bin:$HOME/bin
export PATH

How to import existing ROR project?

I'm new to Ruby on Rails (PHP developer here) and I need to edit an existing ROR project. I've been using Aptana Studio for my PHP projects (switched to Zend after Aptana 2.0) but I've kept Aptana RadRails for my ruby projects.
So what I want to do is to get the ROR project from the server (it's hosted on some linux machine) and import it into RadRails for local development. I've downloaded the files from the server and imported them in a new RadRails ROR project but it doesn't work as intended. Is there anything else I should do ? I've read about 'freezing the gems', switching to production mode and dumping the database for a ROR project upon releasing. Are there some steps needed to undo those operations ?
UPDATE:
The problem that I'm having is that I get various errors when trying to visualize in the browser the pages for different controllers.
ActionController::InvalidAuthenticityToken in
No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).
OR
no such file to load -- xml
This error occurred while loading the following files:
hotels_pro
xml
This leads me to believe that (maybe) I haven't got all the files. On the other hand I have double-checked and I have all the files from the server.
Thanks,
A RoR application is more than just the sum of its source files. There's also the database, gems and a server which exist outside the project directory. Without knowing exactly what doesn't we can only speculate which is causing you problems. Being new to Rails, it's probably all of them. If after all this you're still not up and running a few rounds of "Google the Error" should fix you up.
You'll need to set these things up in your development environment before you can proceed. The following assumes you have a working ruby environment: rubygems installed with the rails, and rake gems. Note any commands and paths that follow are relative to the root of your rails project.
Database:
Start with editing config/databases.yml to find out which database your app will try to connect to. Change it if necessary so it names a local database. Create that database, if it doesn't exist with $rake db:create
If you need existing data to test with you can take a dump from your production database and import it into your working database. How to do this is dependent on the type of database in question. Otherwise you can run the migrations with $ rake db:migrate to produce your development database (assuming the previous developer designed the database with migrations.)
Gems:
Check the config/environment.rb, for your list of required gems. Install all these gems if they haven't been already.
If you're using Rails 2.1 or newer, you can streamline this process by ensuring that all gems are required using the newer config.gem 'this_gem' form instead of older require 'this_gem' declaration. Once all required gems are in this form, you can use $ rake gems:install && rake gems:build to ensure they're all installed.
Server:
Is pretty trivial, all rails instalations come with web brick which is fine for development. But mongrel is also suitable.
P.S. If you're not using some kind of revision control it's strongly advised to set something up before starting. It's not a requirement, but it will likely save your ass at some point.

How to begin with Ruby on Rails using Windows

I've tried downloading the Rails package and installing it on Windows, but have no idea to make it work.
I have had some experience with this commbination:
PHP 4.x + 5.x (Windows)
LIGHTTPD (Windows)
Connecting to a Firebird Database (Windows)
Can anybody enlighten me?
I've gotten Rails up and running on Windows just following the instructions on the RoR website. To paraphrase:
Download Ruby Windows installer from here. I recommend this one.
Execute the .exe [ruby186-26.exe]
Verify your Windows environment variables now includes C:\ruby\bin in the PATH variable. (My Computer -> Properties -> Advanced -> Environment Variables). If it's not there, add it.
Download Ruby Gems from here.
Extract the zip [rubygems-1.3.0.zip] to a temporary directory.
Open a command window and cd to the temp directory.
Type ruby setup.rb in the command window and hit enter.
After that from the command window type gem install rails
Boom! You have rails on windows.
I've heard good things about Instant Rails I've avoided it though. I highly recommend RadRails for Eclipse. I do all my RoR development in Windows using RadRails to connect to a MySQL database.
Either try Instant Rails, which hasn't been updated in a while.
Or try this tutorial and install everything yourself: http://beans.seartipy.com/2008/06/09/setting-up-rails-development-environment-on-windows-vistaxp/
If you're really beginning and have no special attachment to the stuff you've downloaded, try getting the latest Netbeans (v6.1) which comes with Ruby and Rails build in. Its massively simple to install and get running. (A double click install). Then, once you've done that do a "File > New Project > Ruby > Ruby On Rails Application", press F6 and you'll be looking at the start page of your first Rails App.
To get to grips with it all, I'd suggest Sang Shin's free Ruby On Rails course. Its been running a while, but its free, is hands on, has some excellent material, and covers a great deal. I'm doing it and have learned a lot about Rails and Ruby also.
HTH
I use Heroku this is the Signup page for all my Rails Development
You don't have to install or set up anything and you are up and running Fast.
Also, this is a good tutorial for setting up Instant Rails on Vista:
You should really consider just install a Virtual Machine using VMWare if possible. You can still get start with Windows, but you could come across a lot of hiccups on various packages you want to use. I was from Windows too... now I switched myself to a mac and never looked back....
The point is, Ruby runs just a lot better on any POSIX other than using Windows, so its better not to try forcing anything suppose to work properly on one platform on another one. Practically, you will NEVER consider hosting a rails application in Windows (similarly, I doubted if you should ever consider hosting a PHP app in Windows too... you are just putting more cost to hurt your own feet by doing so...)
Another possibility is try to get Ubuntu setup on a USB memory/ hard drive and boot using that when you want to play Rails, slightly problematic, but better performance.
NetBeans as suggested as beginner IDE is good. Although if you get start properly with a good book (Pragmatic defacto Rails book 3rd edition is a good choice, you will never put that one down even after so long as the references are just too useful). Alternatively Rails Guide is something you shouldn't miss.
These are the best tutorials that I have seen for setting up rails on Windows.
Xp: http://www.buildingwebapps.com/articles/6467-setting-up-rails-on-windows-xp
Vista: http://www.buildingwebapps.com/articles/6491-setting-up-rails-on-windows-vista
I used this tutorial just yesterday and it worked well. BUT you need to install RubyGems yourself, after installing Ruby and before installing Rails. I found this guide helpful for RubyGems installation.
I was not able to use an environment variable to set up the http proxy; instead I must pass that as a param on the CL when installing gems (-p [myproxy].[mysite]:[port])
Late to the party, but could you try this tutorial instead?
Getting Started with Rails and MySQL
Two observations:
--source http://gems.rubyinstaller.org is no longer needed. remove that part from the command
Install latest RC1 for either 1.9.1 or 1.8.6 from here
Hope that helps
Here's some tools that have helped me in Windows for general RoR development
TextMate-like editor: http://www.e-texteditor.com/
Multi-tab SSH client: http://www.vandyke.com/products/securecrt/index.html
Full featured UNIX shell (including git): http://code.google.com/p/msysgit/
I just followed this tutorial, and it worked great the first time, and gives steps to take if you encounter common errors. I HIGHLY recommend it. it's one of the best tutorials I've ever gone through. I'm an ASP .NET guy, and I had no trouble.
My suggestion is to begin with a microframework. Something like Sinatra. You can move to Rails / Merb afterwards.
checkout Rails Windows Installer
it installs :
Ruby 1.8.7-p330
Rails 3.0.3
Git 1.7.3.1
Sqlite 3.7.3
DevKit
Rubystack is a free, all-in-one installer for Windows that installs Apache, MySQL, Ruby, Rails and all other third-party libraries typically used on a development environment (such as Imagemagick). We include PHP as well, but no lighttpd

Resources