Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
what does
code:
which ruby
say?

Regardless of if multiple ruby binaries show up for some retarded reason (which is my lame guess atm), I'd be happy to dick around in an irc room or on AIM and get you up and running. I like playing around with new frameworks, but I loathe getting them setup because of crap like this.

dustgun fucked around with this message at 04:24 on Aug 19, 2009

Adbot
ADBOT LOVES YOU

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!
1.8.6, no other version.

AIM is wagedomain if you want to try and help out, but I'll probably be idling all night until tomorrow.

NotShadowStar
Sep 20, 2000

Myrddin Emrys posted:

Total newbie here, just picked up my first RoR book and tried my hand at installing it on Linux.

Dear God, I have the anti-Linux touch. Give me a Linux box, any box, and I will crash it within minutes doing normal things.

Installation of ruby 1.9 was a success, as was gems. Installation of rails failed, because as it turns out OH WAIT ruby wasn't installed. Synaptic and apt-get both reported that ruby was installed, but when I checked the location it spit out, there was nothing there. No folder, no files, nothing. It lied to me :(

So, new distro, and here we go again.

I really don't want to be a human being, but do you have a Mac around? 10.5 works completely out of the box, Apple made everything work perfectly, all you need to do is 'sudo gem update' from a fresh install and you're ready to rock.

I have to go through a few pits of hell every time I try and get Ruby going on Ubuntu. They way the maintainer packaged it makes it all kinds of hosed up. I always end up compiling from source, but then I have to track down a dozen -devel libraries from the repos.

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!

NotShadowStar posted:

I really don't want to be a human being, but do you have a Mac around? 10.5 works completely out of the box, Apple made everything work perfectly, all you need to do is 'sudo gem update' from a fresh install and you're ready to rock.

I have to go through a few pits of hell every time I try and get Ruby going on Ubuntu. They way the maintainer packaged it makes it all kinds of hosed up. I always end up compiling from source, but then I have to track down a dozen -devel libraries from the repos.

No, sorry. I had a macbook a year or so ago but I couldn't stand the keyboard. I am a fast typer and it literally could not keep up with my typing, so I ditched it. Got a Toshiba Satellite but that fell off a bus and broke. I'm working now on a netbook (which I am pleasantly surprised runs Linux and Windows 7 incredibly well).

I no longer have a Windows install on it though. I'm also shopping around for a kickass but relatively inexpensive gaming laptop, but the netbook's all I've got for now.

Pardot
Jul 25, 2001




NotShadowStar posted:

I have to go through a few pits of hell every time I try and get Ruby going on Ubuntu. They way the maintainer packaged it makes it all kinds of hosed up. I always end up compiling from source, but then I have to track down a dozen -devel libraries from the repos.

Not only that, but the ubuntu compiled ruby is supposed to have some performance problems that you don't get if you build ruby yourself. However, I use ruby enterprise edition on our one ubuntu CI box.

NotShadowStar
Sep 20, 2000

Myrddin Emrys posted:

No, sorry. I had a macbook a year or so ago but I couldn't stand the keyboard. I am a fast typer and it literally could not keep up with my typing, so I ditched it. Got a Toshiba Satellite but that fell off a bus and broke. I'm working now on a netbook (which I am pleasantly surprised runs Linux and Windows 7 incredibly well).

I no longer have a Windows install on it though. I'm also shopping around for a kickass but relatively inexpensive gaming laptop, but the netbook's all I've got for now.

Don't ever try and work with Ruby on Windows. Lots of C-based Ruby libraries expect gcc which of course you don't get on Windows. Either the maintainer or some volunteer built a binary for you to use or you're totally screwed. sqlite is a major one. I've been doing Ruby for about 4-5 years and I still hit a brick wall hard when it comes to working on Windows.

I can try and walk you through a compile and install, or if you can give a user-level temporary shell I can build everything and you can do the final install. I wish the Ruby maintainer in Ubuntu/Debian would just give up, this is a really really common problem and they don't know what they're doing.

niralisse
Sep 14, 2003
custom text: never ending story

Sewer Adventure posted:

I know it is quite un-rails but is there an equivalent of php output buffering (ob_start) in rails? I'm trying to store the result of a partial for a particular object in the db rather than render it every time.

If it's for caching purposes stick with fragments, but if it's something else you can use capture.

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!

NotShadowStar posted:

I can try and walk you through a compile and install, or if you can give a user-level temporary shell I can build everything and you can do the final install. I wish the Ruby maintainer in Ubuntu/Debian would just give up, this is a really really common problem and they don't know what they're doing.

Sure, a walkthrough would be great, definitely have to be complete with versions as I've learned certain versions of rails/ruby/gems don't work together nicely.

I did try a manual build/install (whee ./configuration, make, sudo make install!) I ran into issues with this once though, as I'm not a super awesome linux guru, I had no idea how to UNINSTALL something that I built myself - so synaptic and the filesystem got out of whack.

dustgun posted:

what does
code:
which ruby
say?

Regardless of if multiple ruby binaries show up for some retarded reason (which is my lame guess atm), I'd be happy to dick around in an irc room or on AIM and get you up and running. I like playing around with new frameworks, but I loathe getting them setup because of crap like this.

I realized I gave you my output for ruby -v, not a which. Which says /usr/local/bin/ruby.

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!
Well, my friend tried installing ruby/rails/gems on Debian and had no issues. I couldn't even INSTALL Debian because it's a netbook, and booting from the USB worked but it bitched at me for not being a "CD-ROM", like it was hardcoded in the installer or something.

So, now I'm going to try Fedora 11. Myrddin Emrys: breaking Linux one distro at a time! :c00l:

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!
Happy update!

Installed Fedora 11 and used yum to install ruby/gems/rails and no more errors :D I can now do the book's exercises!

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
Hooray. I felt horrible last night when I realized I'd totally spaced out and forgotten about my offer to help out on AIM.

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!

dustgun posted:

Hooray. I felt horrible last night when I realized I'd totally spaced out and forgotten about my offer to help out on AIM.

Haha no worries.

I'm liking what I see so far, though admittedly I haven't delved too deep. It's a refreshing change from .NET, though.

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys
I know ruby 1.8 but never so much as glanced at 1.9 until I saw how god damned fast it was and that rails now supports it. I know 1.9 has some major, incompatible changes with 1.8, so what's the best way to learn it? Is there a webpage out there with a list of changes, and is that enough to learn 1.9? Or should I get the new 1.9 pickaxe to compliment my 1.8 pickaxe? What about O'Reilly's 'The Ruby Programming Language'? A lot of people are saying it's better than the pickaxe, and it says it covers both 1.8 and 1.9, but it was published 18 months ago, is the 1.9 info still accurate?

NotShadowStar
Sep 20, 2000
I hated the Pickaxe. It reads like a Java refugee's first trip with Ruby, and in reality that's exactly what it is. Dave Thomas used to be a Java dude and discovered Ruby, so you see this weird Java-Rubyish naming convention and Java style programming.

The Ruby Programming Language co-written by Matz points out the differences between 1.8 and 1.9 where applicable. That book is good for a reference instead of learning. There really isn't THAT big of a difference between 1.8 and 1.9 if you're doing pure Ruby. I suggest just doing what you always do using 1.9, then consult the RPL book if things go wrong.

sorghum
Jul 9, 2001
Did anyone here do Rails Rumble this year?

I worked on morsurl.com, which is a URL shortener that lets you add highlighting to the page you're linking to. We got a bit of a late start but I'm still pretty happy with what we got done in that time.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
I've spent all day trying to get prawnto & prawn to render layouts. I want to shoot myself in the face and I think I'm just going to hack something up so that ... something something and then it works.

In short, someone make a better PDF creation plugin for rails.

Operation Atlas
Dec 17, 2003

Bliss Can Be Bought

dustgun posted:

I've spent all day trying to get prawnto & prawn to render layouts. I want to shoot myself in the face and I think I'm just going to hack something up so that ... something something and then it works.

In short, someone make a better PDF creation plugin for rails.

What's wrong with pdf-writer?

Magicmat posted:

I know ruby 1.8 but never so much as glanced at 1.9 until I saw how god damned fast it was and that rails now supports it. I know 1.9 has some major, incompatible changes with 1.8, so what's the best way to learn it? Is there a webpage out there with a list of changes, and is that enough to learn 1.9? Or should I get the new 1.9 pickaxe to compliment my 1.8 pickaxe? What about O'Reilly's 'The Ruby Programming Language'? A lot of people are saying it's better than the pickaxe, and it says it covers both 1.8 and 1.9, but it was published 18 months ago, is the 1.9 info still accurate?

There aren't really that many differences. Just update your ruby binary and run your old projects and see what breaks. My main project (~5000 LOC) only had 2 or 3 places that required minor changes. Took maybe 30 minutes to upgrade. The biggest gotcha had something to do with require and load paths, but I can't remember the specific problem at the moment.

Kimani
Dec 20, 2003

Anime avatar - check
ADTRW poster - check
Defends watching child porn - CHECK!!!
Help me out, guys. This is a painful wall I've been running into for the last several hours, and I'm unable to Google anything useful. This is probably something more Ruby and less Rails specific, but this is still probably the better thread to ask the question, as it's still Rails related.

So I'm making my blog in Rails, and I want to intermingle my blog posts with Facebook status updates. The two ways I've looked into to access the Facebook status updates are:

1. Use Facebooker to access the data. The problem with this is that I don't think it's meant to work quite like that - it seems to be more about allowing the user log in and access their data as opposed to having the application log in and access a single user's data.

2. Use my status RSS feed. This is the one I need some assistance with.

So I found this link which allowed me to get an RSS feed of my own status updates. I then found this page which pointed me in the direction of opening/parsing that RSS feed. Everything comes together, right? Nope.

When I run the code in that last link, the content of 'response' is not the XML of the RSS feed I want, but it's the Facebook page telling me that I'm using an incompatable web browser.

Yes, ruby's 'open' is not Firefox, IE, etc. My question is - how do I get around this and make ruby's open function identify as a given browser? Or what else should I do instead of use open?

Kimani fucked around with this message at 11:28 on Aug 28, 2009

NotShadowStar
Sep 20, 2000
Which direction are you wanting to go, pulling from facebook to blog or from blog to facebook?

sorghum
Jul 9, 2001
You can pass HTTP headers when opening a URL by including them in a hash as the second parameter (documentation here). For example:
code:
document = open('http://www.facebook.com/feeds/status.php?id=XXXX&viewer=XXXX&key=XXXX&format=rss20',
  'User-Agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2'
).read
That's got to be a bug though. I don't see why they'd want to check for a supported browser when serving a RSS feed.

Kimani
Dec 20, 2003

Anime avatar - check
ADTRW poster - check
Defends watching child porn - CHECK!!!

NotShadowStar posted:

Which direction are you wanting to go, pulling from facebook to blog or from blog to facebook?
Facebook to blog.

sorghum posted:

You can pass HTTP headers when opening a URL by including them in a hash as the second parameter (documentation here).
Yup, this works. I tried to look at the documentation for open before, but I didn't see that. Guess I'm not used to sifting through ruby docs.

Thanks!

Fangs404
Dec 20, 2004

I time bomb.
So I'm fairly new to RoR, and I'm really liking it. I've been maintaining a site that was built before I got here. I have kind of a strange migration question, though.

So right now, according to script/about, we're running Ruby 1.8.6 and Rails 1.2.3:

code:
Ruby version                 1.8.6 (x86_64-linux)
RubyGems version             0.9.4
Rails version                1.2.3
Active Record version        1.15.3
Action Pack version          1.13.3
Action Web Service version   1.2.3
Action Mailer version        1.3.3
Active Support version       1.4.2
However, when I run rails -v and ruby -v from the command line, I see that we have Rails 2.2.2 and Ruby 1.8.6. What's with the discrepancy in Rails versions? We're looking to migrate to Rails 2 which is why I was kinda shocked when I saw that we supposedly have Rails 2.2.2 installed.

Pardot
Jul 25, 2001




Fangs404 posted:

What's with the discrepancy in Rails versions?

You can have any number of versions of any gem, including rails. The app itself is picks which one to use, which doesn't have to be the most recent version you have installed. As an aside, you don't have the newest version that's been released which is 2.3.4.

In config/environment.rb check to see if there is RAILS_GEM_VERSION = '1.2.3'. I don't really remember 1.2, so it might be different back then. That's how you set which version to use now. Or, check to see if you have rails vendored in vendor/rails.

Also, be aware that rails 3 is due out soon.

manero
Jan 30, 2006

Pardot posted:

Also, be aware that rails 3 is due out soon.

Really? Last I heard, a November release was going to be iffy.

Fangs404
Dec 20, 2004

I time bomb.

Pardot posted:

You can have any number of versions of any gem, including rails. The app itself is picks which one to use, which doesn't have to be the most recent version you have installed. As an aside, you don't have the newest version that's been released which is 2.3.4.

In config/environment.rb check to see if there is RAILS_GEM_VERSION = '1.2.3'. I don't really remember 1.2, so it might be different back then. That's how you set which version to use now. Or, check to see if you have rails vendored in vendor/rails.

Also, be aware that rails 3 is due out soon.

Ah, I do indeed see RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION. So if I understand you right, all I have to do to migrate to 2.x is change that line to say RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION (once we update to 2.3.4 from 2.2.2), run rake rails:update, update plugins, and fix any bugs that we encounter?

jonnii
Dec 29, 2002
god dances in the face of the jews
I highly recommend vendoring your rails.

Fangs404
Dec 20, 2004

I time bomb.

jonnii posted:

I highly recommend vendoring your rails.

I'll check into this. I don't even know what that means.

[edit]
Oh, snap, this looks great. Sounds like it'll make pushing our test code to the live server a whole lot simpler. I'll definitely look more into this. Thanks.

jonnii
Dec 29, 2002
god dances in the face of the jews

Fangs404 posted:

I'll check into this. I don't even know what that means.

[edit]
Oh, snap, this looks great. Sounds like it'll make pushing our test code to the live server a whole lot simpler. I'll definitely look more into this. Thanks.

Additionally I suggest vendoring everything you can. Plugins, gems, the works. It's really easy to do it now in rails 2.x:

In environment.rb

config.gem "thoughtbot-clearance",
:lib => 'clearance',
:source => 'http://gems.github.com',
:version => '0.8.2'

Then you can run:

rake gems:install
rake gems:unpack

NotShadowStar
Sep 20, 2000
In essence you can copy Rails into the project instead of relying on system-installed Rails. It's good for keeping things static.

Is this a public server? I'd be scared running 1.x of Rails because of the litany of vulnerabilities that have sprung up since then.

Fangs404
Dec 20, 2004

I time bomb.
Thanks for the info guys. Vendoring definitely sounds like it's the way to go.

And yeah, this is a public live server. I kind of inherited this project, and upgrading Rails is my top priority.

Donald Duck
Apr 2, 2007
I'm following a tutorial(You need to register to view it) from IBM; have downloaded RoR and the gems I need. I'm using Windows Vista.
I've created a new project and then I run the command "ruby script/server". This appears to run fine. However, when I enter "http://localhost:3000/" into my browser it can't find the page.
I've tried googling around but no one else seems to have gotten this problem. I tried one solution attempt of reseting winsock but it didn't do anything. When I ran the server first I told the firewall to unblock it and I've tried running it with the firewall off.
It's probably something extremely obvious but I'm at a loss. Any ideas?

darqness
Jul 20, 2006

Donald Duck posted:

I'm following a tutorial(You need to register to view it) from IBM; have downloaded RoR and the gems I need. I'm using Windows Vista.
I've created a new project and then I run the command "ruby script/server". This appears to run fine. However, when I enter "http://localhost:3000/" into my browser it can't find the page.
I've tried googling around but no one else seems to have gotten this problem. I tried one solution attempt of reseting winsock but it didn't do anything. When I ran the server first I told the firewall to unblock it and I've tried running it with the firewall off.
It's probably something extremely obvious but I'm at a loss. Any ideas?

Stupid suggestion but try 127.0.0.1. One of the guys at work has to do this :iiam:

Donald Duck
Apr 2, 2007

darqness posted:

Stupid suggestion but try 127.0.0.1. One of the guys at work has to do this :iiam:
edit:

That worked actually, didn't work the first time but did after that.

Any idea why that happens?

darqness
Jul 20, 2006

Donald Duck posted:

edit:

That worked actually, didn't work the first time but did after that.

Any idea why that happens?

I have only seen it happen on thinkpads. So I am guessing it is that super enterprise wireless tool that comes with them.

NotShadowStar
Sep 20, 2000
Could try pinging localhost from the command line, but yeah some wireless 'management programs' gently caress with the network settings and break normal stuff.

Also, that tutorial is 2.5 years old and likely very, very wrong just by reading the blurb. I don't have an IBM account but a huge number of things have changed since 1.2. We're almost at 3.0. If you're really interested in Rails, use The Book.

Sewer Adventure
Aug 25, 2004

Donald Duck posted:

edit:

That worked actually, didn't work the first time but did after that.

Any idea why that happens?

add the following line to c:\windows\system32\drivers\etc\hosts
127.0.0.1 localhost

HIERARCHY OF WEEDZ
Aug 1, 2005

What's the cleanest way to represent this idea?

I have a model, and different links to different actions on different controllers related to that model. It's not very RESTful, I'm afraid, but that's not the priority of the project; however it means I can't use the nice automagic RESTful URL helpers

There are two conditions, an initial condition and a secondary condition.
So if the initial condition is true, I don't want to return a link at all.
If the initial condition is false, and the secondary condition is true, then I want to return a hyperlink with text "Create Foo" and a link to FoosController#new.
If the initial condition is false, and the secondary condition is false, then I want to return a hyperlink with text "Edit Foo" and a link to FoosController#edit.

Right now I have something like this in the model:

code:
  def foo_url
    return nil, nil if self.initial_condition
    return 'Create Foo',   { :controller => :foos, :action => :new } if self.secondary_condition
    return 'Edit Foo',     { :controller => :foos, :action => :edit }
  end
And then both return values get passed to link_to in the controller. I know about link_to_if but it's still kind of unwieldy to use it.

Operation Atlas
Dec 17, 2003

Bliss Can Be Bought

Panic! at the Fist Jab posted:

What's the cleanest way to represent this idea?

First: You're violating MVC in an extreme way. Models should not ever know about controllers or URLs or routes or any of that stuff. This kind of logic should be in the helper, if it should exist at all.

I have a suspicion that you're trying to do something that you don't have to be doing at all. Can you elaborate a bit further on what you're trying to really do?

Here's how it should be done if you're going to do it at all (in ApplicationHelper or FoosHelper, depending on where it is used):

code:
def foo_url(a_foo)
  if a_foo.initial_condition
    ""
  elsif a_foo.secondary_condition
    link_to 'Create Foo', { :controller => :foos, :action => :new 
  else
    link_to 'Edit Foo',     { :controller => :foos, :action => :edit }
  end
end

HIERARCHY OF WEEDZ
Aug 1, 2005

I know it violates MVC, that's why I was asking. All I'm trying to do is have a list of links, each one with subtly different logic for when they should show up on a page. I finally decided upon this in the view, which I can tear out into a partial if it turns out it needs to be duplicated:

code:
<%= link_to_unless(bar.secondary_condition, 'Create Foo', { :controller => :foos, :action => :new }) do
    link_to('Edit Picks', { :controller => :foos, :action => :edit })
  end unless bar.initial_condition -%>

Adbot
ADBOT LOVES YOU

NotShadowStar
Sep 20, 2000
The helper is exactly right. Models are strictly for data, the further you go down the route of your model doing view stuff the harder everything is going to be on you later. You also don't want convoluted logic in your view because in a couple months you are going to go :wtc: trying to figure out your view.

But after looking at it a bit and whipping something up something seems really off. Why do you want to create a new record if there is some condition on an existing model instance?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply