TwelvestoneBack End

Ruby Newbie


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Media44
 
2011-03-12

Alright to begin my fortay into Ruby before even starting the book I picked up I found my way to this site, which I'm really enjoying and I find the language quite intuitive thus far though there are a few things I don't get yet.

My main question right now though is it had me type this in:

Popup.make { h1 "My Links" link "Go to Google", "http://google.com/" }

When I hit enter it opened a popup with Google in it. What I thought was going to occur was it would open a window with a h1 heading of "My Links" and then either a new line or right next to that have it be a link reading Go to Google which referenceshttp://google.com/

What am I missing that all it did was open up Google or is it perhaps a bug in this website as it is in beta?

Media44
 
2011-03-12

hmm I went on anyways and now I'm fairly sure it must be the website malfunctioning because the code for the next lesson doesn't reference Google at all but still opened Google in a popup.

Popup.make do h1 "Things To Do" list do p "Try out Ruby" p "Ride a tiger" p "(down River Euphrates)" end end

That again pulled up google in the popup window.

Media44
 
2011-03-12

okay so off the online tutorial site and onto the real deal: installation.

based on what I read here:http://rubyonrails.org/download I opened a terminal window and typed in 'gem update rails' and looks like some things got installed but I got 2 warnings and an error message as well and not sure how that will affect me in the long run. This is a read-out of what I got:

Updating installed gems Updating rails WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and /usr/bin aren't both writable. WARNING: You don't have /Users/Dennis/.gem/ruby/1.8/bin in your PATH, gem executables will not run. ERROR: Error installing rails: bundler requires RubyGems version >= 1.3.6 Gems updated: activesupport, builder, i18n, activemodel, rake, rack, rack-test, rack-mount, tzinfo, abstract, erubis, actionpack, arel, activerecord, activeresource, mime-types, polyglot, treetop, mail, actionmailer Installing ri documentation for activesupport-3.0.5... Installing ri documentation for builder-2.1.2... ERROR: While generating documentation for builder-2.1.2 ... MESSAGE: Unhandled special: Special: type=17, text="<!-- HI -->" ... RDOC args: --ri --op /Users/Dennis/.gem/ruby/1.8/doc/builder-2.1.2/ri --title Builder -- Easy XML Building --main README --line-numbers --quiet lib CHANGES Rakefile README doc/releases/builder-1.2.4.rdoc doc/releases/builder-2.0.0.rdoc doc/releases/builder-2.1.1.rdoc --title builder-2.1.2 Documentation (continuing with the rest of the installation) Installing ri documentation for i18n-0.5.0... Installing ri documentation for activemodel-3.0.5... Installing ri documentation for rake-0.8.7... Installing ri documentation for rack-1.2.1... Installing ri documentation for rack-test-0.5.7... Installing ri documentation for rack-mount-0.6.13... Installing ri documentation for tzinfo-0.3.24... Installing ri documentation for abstract-1.0.0... Installing ri documentation for erubis-2.6.6... Installing ri documentation for actionpack-3.0.5... Installing ri documentation for arel-2.0.9... Installing ri documentation for activerecord-3.0.5... Installing ri documentation for activeresource-3.0.5... Installing ri documentation for mime-types-1.16... Installing ri documentation for polyglot-0.3.1... Installing ri documentation for treetop-1.4.9... Installing ri documentation for mail-2.2.15... Installing ri documentation for actionmailer-3.0.5... Installing RDoc documentation for activesupport-3.0.5... Installing RDoc documentation for builder-2.1.2... Installing RDoc documentation for i18n-0.5.0... Installing RDoc documentation for activemodel-3.0.5... Installing RDoc documentation for rake-0.8.7... Installing RDoc documentation for rack-1.2.1... Installing RDoc documentation for rack-test-0.5.7... Installing RDoc documentation for rack-mount-0.6.13... Installing RDoc documentation for tzinfo-0.3.24... Installing RDoc documentation for abstract-1.0.0... Installing RDoc documentation for erubis-2.6.6... Installing RDoc documentation for actionpack-3.0.5... Installing RDoc documentation for arel-2.0.9... Installing RDoc documentation for activerecord-3.0.5... Installing RDoc documentation for activeresource-3.0.5... Installing RDoc documentation for mime-types-1.16... Installing RDoc documentation for polyglot-0.3.1... Installing RDoc documentation for treetop-1.4.9... Installing RDoc documentation for mail-2.2.15... Installing RDoc documentation for actionmailer-3.0.5...

Stinky
 
2011-03-12

gem upgrade

Will take care of your first warning. Also when you install rails do

gem install rails --no-rdoc --no-ri

And you won't end up wasting as much time generating documentation.

Media44
 
2011-03-12

so what I need to do now is type in:

  1. 'gem upgrade'
  2. 'gem install rails --no-rdoc --no-ri'

Then everything will work? It sounds like SQLite3 is just as confusing for initial setup on 10.6 considering I have no idea what any of this means:http://stackoverflow.com/questions/1143776/install-sqlite3-on-mac-osx

Or can I just download the precompiled binaries for Mac?http://www.sqlite.org/download.html

The book I ended up getting starts with an initial project using Scaffolding but I saw you told XD that scaffolding will just confuse beginners. Should I read the book for its knowledge but get a different book (The Rails 3 Way perhaps) for the actual coding aspect?

p.s. I realized I hadn't named the actual site I was playing with in those first two posts it was:http://tryruby.org/ - until I get it installed I'm going to move on and give thishttp://railsforzombies.org/ a try

RobotDeathSquad
 
2011-03-12

Your book covers Rails 2. By doing gem upgrade or gem install rails you're going to get Rails 3, which is a totally different beast. If you are going to do Rails 3, you definitely need to get a different book.

You can totally learn Rails 2 first. There is WAY more info on the web for Rails 2 and WAY more plugins that work with Rails 2 than 3.

gem install rails --version=2.3.11 will give you the newest Rails 2.

You definitely want to install homebrew so you can install all the things (like SQLite) easier. Use the instructions on my blog for that.

I have all those things on my blog because those are actually all the tools I use. You could skip git at first, but you want to start learning source code management very quickly.

(Git, XCode, Homebrew, rvm, Ruby Enterprise Edition, Passenger, PassengerPane)

Lets see: Git = Source Code Management, Skip. XCode = Developer Tools for compiling software on OS X. Need this for Homebrew and SQLite and others. Homebrew = Tool to install developer tools such as SQLite (and most other things here) very easily. It's fake package management like you'd use on Linux. RVM = ruby version manager. Lets you easily install different versions of ruby easily. REE = Ruby enterprise edition. Skip this. Passenger = Lets Apache run ruby. You can skip this at first, but as soon as you have more than one rails app you are messing with, you'll want that. Passenger Preference Pane = A preference pane for setting up multiple rails sites easily in your System Preferences instead of messing about with apache config files. Install after passenger. MySQL = Better database than SQLite. Skip for now

How experienced with Linux are you?

Media44
 
2011-03-12

I have 0 experience on Linux past trying out Edubuntu on a friends laptop one time.

Damn the book I bought is nonrefundable since I bought it at a going out of business sale. But the reason I like it is because its textbook like approach explaining what each element is. I guess I'll keep it as bathroom literature to help understand ROR but try to find a book on Rails 3 - doesn't make sense to me to learn Rails 2 when Rails 3 is already out.

cfoley
 
2011-04-13

Rails 3 way is great. I started rails way back before 2 but just dabbled.

Seems like with 3 scaffolding is frowned upon. I found it easier to scaffold then hard code. My special method of TDD I guess.

Anyway, stick with it. There's a sweet spot with rails - after about a month it all clicks together and an Ah-ha moment happens.

I'm loving 3 right now but the move has put me way off schedule and I'll probably have to start all my tuts from the start. I'd highly recommend getting a subscription to Lynda.com. $25 p/m but you can cancel anytime.

Also get to respect TDD. It'll save your ass over & over but it's difficult to see the point of it until it actually saves your ass.

Media44
 
2011-07-07

So I finally bought The Rails 3 Way when I had some spare money to spend.

I'm trying to get it installed and running into all sorts of problems. I posted on this Rails forum but only got one response really of any use and it didn't solve anything.

http://railsforum.com/viewtopic.php?id=44514

I think the first thing I need to do is get RVM working. When I tried that this is what occurred:

dennis-xxxxxxxx-macbook-pro:~ Dennis$ bash < <(curl -shttps://rvm.beginrescueend.com/install/rvm) bash: line 151: git: command not found bash: line 153: git: command not found

ERROR: Unable to clone the RVM repository, attempted both git:// and https://

dennis-waxbergs-macbook-pro:~ Dennis$

Anyone got clues as to how to fix it so that RVM works so I can then try figuring out how to get the correct version of Rails and Ruby?

the real me
 
2011-07-07

It looks like you don't have git installed. http://git-scm.com/

Media44
 
2011-07-08

Thanks that seemed to do the trick so now RVM installed, hopefully all the rest now installs easily as well! :beer:

Media44
 
2011-07-08

Damnit nope. Why the hell is this so hard just to get installed. I'm not even programming yet :,(

Last login: Thu Jul 7 21:37:26 on ttys000 dennis-xxxxxx-macbook-pro:~ Dennis$ rvm install 1.9.2 -bash: rvm: command not found dennis-xxxxxx-macbook-pro:~ Dennis$ rvm -bash: rvm: command not found dennis-xxxxxxx-macbook-pro:~ Dennis$ sudo gem update rails Password: Updating installed gems Updating rails ERROR: Error installing rails: bundler requires RubyGems version >= 1.3.6 Nothing to update dennis-xxxx-macbook-pro:~ Dennis$ update --head -bash: update: command not found dennis-xxxxx-macbook-pro:~ Dennis$ rvm update --head -bash: rvm: command not found dennis-xxxxx-macbook-pro:~ Dennis$

I did the GIT install then the RVM and it seemed to install properly and then gave me a message about how to find Wayne on IRC and whatnot.

Since it mentioned RubyGems I did a quick search and found a code so tried to run it of course like everything else it didn't work: dennis-xxxxxx-macbook-pro:~ Dennis$ gem update --system Updating RubyGems Updating rubygems-update ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /Library/Ruby/Gems/1.8 directory. dennis-xxxxxx-macbook-pro:~ Dennis$

Went in to Finder and checked that folder out and changed the permissions on it so everyone has read/write permissions, applied it to everything contained within. Ran the code again and the same error came up.

Oh snap I figured something out! Someone on that other forum told me about Sudo and I don't fully grasp it but remembered reading a little about it so ran this and it seems to have worked.

dennis-xxxxxxx-macbook-pro:~ Dennis$ sudo gem update --system Password: Updating RubyGems Updating rubygems-update Successfully installed rubygems-update-1.8.5 Updating RubyGems to 1.8.5 Installing RubyGems 1.8.5 RubyGems 1.8.5 installed

=== 1.8.5 / 2011-05-31

  • 2 minor enhancement:

    • The -u option to 'update local source cache' is official deprecated.
    • Remove has_rdoc deprecations from Specification.
  • 2 bug fixes:

    • Handle bad specs more gracefully.
    • Reset any Gem paths changed in the installer.

RubyGems installed the following executables: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem

dennis-xxxxxx-macbook-pro:~ Dennis$

Of course my goal is to get Ruby 1.9.2/Rails 3.0.1 since thats what the guide uses and still not there yet.

Went back to RVM webpage to look for clues and realized there are two additional steps to get it worker after install. Another script to load it and then a script to test its working. Ran that and now we're up. It also said to check for other things in the notes and how to do that. The notes say I should install Xcode Tools 3.2.1 or later so looks like that's the next step on this journey.

Last login: Thu Jul 7 21:39:25 on ttys000 dennis-xxxxxxx-macbook-pro:~ Dennis$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile dennis-xxxxx-macbook-pro:~ Dennis$ source .bash_profile dennis-xxxxx-macbook-pro:~ Dennis$ type rvm | head -1 rvm is a function dennis-waxbergs-macbook-pro:~ Dennis$ rvm notes

Notes for Darwin ( Mac OS X ) For Snow Leopard be sure to have Xcode Tools Version 3.2.1 (1613) or later You should download the latest Xcode tools from developer.apple.com. (This is since the dvd install for Snow Leopard contained bugs).

If you intend on installing MacRuby you must install LLVM first.
If you intend on installing JRuby you must install the JDK.
If you intend on installing IronRuby you must install Mono (version 2.6 or greater is recommended).

To seamlessly abandon the Apple-installed system ruby (ruby 1.8.7 patchlevel 174 for Snow Leopard):

rvm install 1.8.7 # installs patch 302: closest supported version
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system # migrate your gems
rvm --default 1.8.7

dennis-xxx-macbook-pro:~ Dennis$

Media44
 
2011-07-09

okay so it seems Xcode isn't free at all so forget that. On to once again trying to update.

dennis-xxxxxx-macbook-pro:~ Dennis$ rvm install 1.9.2 Installing Ruby from source to: /Users/Dennis/.rvm/rubies/ruby-1.9.2-p180, this may take a while depending on your cpu(s)...

ruby-1.9.2-p180 - #fetching ruby-1.9.2-p180 - #downloading ruby-1.9.2-p180, this may take a while depending on your connection... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 8609k 100 8609k 0 0 448k 0 0:00:19 0:00:19 --:--:-- 754k ruby-1.9.2-p180 - #extracting ruby-1.9.2-p180 to /Users/Dennis/.rvm/src/ruby-1.9.2-p180 ruby-1.9.2-p180 - #extracted to /Users/Dennis/.rvm/src/ruby-1.9.2-p180 Fetching yaml-0.1.3.tar.gz to /Users/Dennis/.rvm/archives % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 455k 100 455k 0 0 263k 0 0:00:01 0:00:01 --:--:-- 425k Extracting yaml-0.1.3.tar.gz to /Users/Dennis/.rvm/src Configuring yaml in /Users/Dennis/.rvm/src/yaml-0.1.3. ERROR: Error running ' ./configure --prefix="/Users/Dennis/.rvm/usr" ', please read /Users/Dennis/.rvm/log/ruby-1.9.2-p180/yaml/configure.log Compiling yaml in /Users/Dennis/.rvm/src/yaml-0.1.3. ERROR: Error running '/usr/bin/make ', please read /Users/Dennis/.rvm/log/ruby-1.9.2-p180/yaml/make.log Installing yaml to /Users/Dennis/.rvm/usr ERROR: Error running '/usr/bin/make install', please read /Users/Dennis/.rvm/log/ruby-1.9.2-p180/yaml/make.install.log ruby-1.9.2-p180 - #configuring ERROR: Error running ' ./configure --prefix=/Users/Dennis/.rvm/rubies/ruby-1.9.2-p180 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/Dennis/.rvm/usr ', please read /Users/Dennis/.rvm/log/ruby-1.9.2-p180/configure.log ERROR: There has been an error while running configure. Halting the installation. dennis-xxxxxx-macbook-pro:~ Dennis$ rails -v /Library/Ruby/Site/1.8/rubygems/dependency.rb:247:in to_specs': Could not find rails (>= 0) amongst [abstract-1.0.0, actionmailer-3.0.9, actionmailer-3.0.5, actionmailer-3.0.3, actionpack-3.0.9, actionpack-3.0.5, actionpack-3.0.3, activemodel-3.0.9, activemodel-3.0.5, activemodel-3.0.3, activerecord-3.0.9, activerecord-3.0.5, activerecord-3.0.3, activeresource-3.0.9, activeresource-3.0.5, activeresource-3.0.3, activesupport-3.0.9, activesupport-3.0.5, activesupport-3.0.3, arel-2.0.10, arel-2.0.9, builder-2.1.2, erubis-2.6.6, i18n-0.5.0, mail-2.2.19, mail-2.2.15, mime-types-1.16, polyglot-0.3.1, rack-1.2.1, rack-mount-0.6.14, rack-mount-0.6.13, rack-test-0.5.7, rake-0.8.7, rubygems-update-1.8.5, treetop-1.4.9, tzinfo-0.3.24] (Gem::LoadError) from /Library/Ruby/Site/1.8/rubygems/dependency.rb:256:into_spec' from /Library/Ruby/Site/1.8/rubygems.rb:1182:in `gem' from /usr/bin/rails:18 dennis-xxxx-macbook-pro:~ Dennis$

Um... ya.... so that's a lot of errors and stuff I don't understand. Any clues?

Media44
 
2011-09-07

So anyone know what these errors mean and how I can fix them and finally start actually making something in Ruby?

Media44
 
2011-09-10

So I ended up putting up a post on Craigslist for a Computer Gig to pay someone to help me get it installed. After some failed attempts the guy discovered its because I don't have a C Compiler and it seems the only option was XCode for $100. So instead he's going to put Ubuntu on VirtualBox and install it on there for me.

I would've never figured this out, glad I decided to go this route.

Stinky
 
2011-09-10

Weird. XCode should be a free download, either from the app store or just pull it off of the extras DVD that came with your mac.

Media44
 
2011-09-10

Everything I see makes you login to Mac Store as a Developer and while the XCode itself is "free" the Developer account is $99/yr

I don't have the Extra DVDs as I got this laptop from my dad when Samoa completely destroyed mine (dim screen, dead wifi card, dead battery, dead cd drive, running on Leopard).

You did give me one of those idea things though - just called Macstore and they tell me they can install XCode for me real fast if I stop by. So I'll give that a go tomorrow.

Stinky
 
2011-09-11

Right on, yeah, it's always been free but I think they did a thing for a while where it cost $5 in the App store. I know for sure that it's free again on Lion.

Media44
 
2011-09-18

Got Textmate all setup and once again am stuck, they really don't make books for beginner's it seems despite what the intro says.

So in Ruby on Rails 3 Tutorial by Hartl it says:

$ cd first_app/ $ mate Gemfile

got that. Now it says:

I therefore recommend updating your Gemfile as in Listing 1.3 by basically changing a line to read "gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

I did that. Then the guide seems to skip and says "Once you've assembled the proper Gemfile, install the gems using bundle install: $ bundle install Fetching source index for http://rubygems.org/"

I don't know if I did the assembly correctly, I basically just saved the file. Then I typed in my terminal bundle install and it gives me an error message that the bundle command isn't found.

This is pretty frustrating getting stuck every single step of the way while using a guide that's supposedly good for absolute beginners. Anyone got an idea of what to do?

Media44
 
2011-09-18

oh here this page actually has the part of the book I'm on so if anyone that might be able to help doesn't know the book: links

Media44
 
2011-09-18

Thanks Stack Overflow, seems the book forgot to mention I have to first run $gem install bundle

Media44
 
2011-09-20

Alright so at this point I'm just going to post regular updates here on my process, making this into my own little blog about following this guide.

I just signed up for GitHub though I only partially understand what it does at this point. Some commands seem to be different than in the book but I'm happy I was able to figure out certain things using the GitHub setup instructions and realizing the reason the push didn't work after that is because I was then in the /.ssh directory and had to navigate back to my project. Baby steps.

On the plus side it looks like markdown is used so I'm gonna get to learn how to use the new forums better.

Done for tonight, next step it says is to get setup on Heroku for deployment.

RobotDeathSquad
 
2011-09-20

Heroku is probably actually easier than Github to setup. It's almost the same process actually.

Media44
 
2011-09-21

Well glad I've been taking notes because it seems I either generated an extra code or I'm not really sure but when setting up Heroku I did the command

heroku keys:add

This gave me two options but I remembered which one it said when I did Git so used the same one for this.

Seems to all be up now at Heroku Test Domain

That's the end of chapter 1. Chapter 2 I believe is a Demo App using Scaffolding before Chapter 3 delves into doing Apps without scaffolding for the rest of the book (at least thats what the introduction said will happen). Not going to start Chapter 2 tonight though.

Media44
 
2011-09-22

Completed Chapter 2 making a quick demo app using Scaffolding. I couldn't get one part to work:

class User < ActiveRecord: :Base

has_many :microposts

end

and

class Micropost < ActiveRecord: :Base

belongs_to :user

validates :content, :length => { :maximum => 140 }

end

Then I tried running as it says:

$ rails console

first_user = User.first

(Results 1)

first_user.microposts

(Results 2)

Results 1 worked but then Results 2 gave me an error. I'm not terribly concerned with this though and am going to just proceed to Chapter 3 to start learning without Scaffolding which will hopefully get the ball rolling. It is pretty cool using the Scaffold though considering I taught myself some PHP a very very long time ago but could never figure out how to do MySQL or setup virtual databases and such and here in only 30 minutes I setup a virtual database, had a form and was able to put in and edit data.

TwelvestoneBack End

Ruby Newbie