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
phazer
May 14, 2003

chirp chirp i'm a buffalo
Hi guys, me again. Sorry I ducked out on the last post. I ended up fixing that problem.

So now I have this new weird one.

I am using acts_as_rateable here: http://github.com/azabaj/acts_as_rateable/tree/master

And on my local box, it works great, as a plugin (.vendor/plugins/acts_as_rateable) but on the production server I get the error "Cannot find association for rates through ratings", so I stuck this

require 'vendor/plugins/acts_as_rateable/lib/rating'

into my environment.rb file, right above the initializer config block, and now I get:

uninitialized constant ActiveRecord from line 1 of that file (class Rating < ActiveRecord::Base)

I don't know what to do, guys. I can provide more info if needed.

Using a webbynode readystack with Ruby 1.8.6, Rails 2.3.2 and Passenger.

Adbot
ADBOT LOVES YOU

Pardot
Jul 25, 2001




phazer posted:

now I get: uninitialized constant ActiveRecord from line 1 of that file (class Rating < ActiveRecord::Base)

Try adding a file in config/initializers/ that does that require. It should run after active record has been loaded then.

edit:

Magicmat posted:

So where do I start? What's the IDE of choice these days on Windows? Does Git's windows support still suck? (Mercurial was the windows guys' distributed versioning system when I last checked, do Rails and Mercurial play nice?) When is Rails 3.0 coming out? If I'm embarking on a moderate-sized project, should I wait to jump back in or just go with the current 2.x version?

I don't really know much about windows except that is painful to do ruby on it. IDEs I have no clue. If netbeans works on windows, that may be okay. I use textmate and have been going over to vim.

Git has gotten better from what I've heard. Look around on the github help, I think there's some tips for windows. At the very least, there is a hg-git bridge so you can use remote git repos but use hg locally.

I think rails 3 is still a few months out. You should just start now, though. I think they said on the railsenvy podcast last week that rails 3 is going to be backwards compatible with 2.3.2.

Pardot fucked around with this message at 18:13 on Jun 26, 2009

phazer
May 14, 2003

chirp chirp i'm a buffalo

Pardot posted:

Try adding a file in config/initializers/ that does that require. It should run after active record has been loaded then.

gently caress yea! That worked! Thanks, dude!

KarmaticStylee
Apr 21, 2007

Aaaaaughibbrgubugbugrguburgle!
Do any of you make basic site on Rails? i.e. sites that would use little Rails functionality

just curious as to at what point you turn to Rails if you see what I mean

NotShadowStar
Sep 20, 2000
Smallest I've done recently is a basic data collection form with a few fields. With templates it took about 15 minutes from 'rails fartlicker' to adding a Mongrel service to a production server.

For super small there's always PHP, but everything I've ever done has never stayed super small despite the initial conversations so personally I'll do Ruby-CGI or Camping+AR unless there's a dire need for PHP.

Pardot
Jul 25, 2001




Sinatra is really great for the super small stuff. Even more awesome, you could later drop it in as rack middleware, but I've never actually had a need to do that myself.

GroceryBagHead
Nov 28, 2000

NotShadowStar posted:

Smallest I've done recently is a basic data collection form with a few fields. With templates it took about 15 minutes from 'rails fartlicker' to adding a Mongrel service to a production server.

For super small there's always PHP, but everything I've ever done has never stayed super small despite the initial conversations so personally I'll do Ruby-CGI or Camping+AR unless there's a dire need for PHP.

And if you used Passenger it would be even faster.

Hammertime
May 21, 2003
stop

GroceryBagHead posted:

And if you used Passenger it would be even faster.

Pretty much ... Nginx + Passenger = Greatest rails webserver combo ever.

NotShadowStar
Sep 20, 2000
Yeah I didn't want to deal with it since the server already serves PHP (4 oh god) with Apache. It's an internal app so I just did a mongrel service on a non-standard port.

Lumi
Apr 26, 2006
I watched the sky.
I was wondering if anyone could help me with something. I've been trying to add a little Javascript to my views, and extracting some of my functions to public/javascripts/application.js, but it doesn't seem to work. It also doesn't help that I'm new to Javascript. What I'm basically doing right now is try to invoke a function from inside application.js

Say inside application.js is
code:
function foo()
{
    alert("check");
}
and inside my view would be

code:
//a bunch of code
<%=javascript_include_tag 'application'%>
<script type = "text/javascript">
function bar()
{
    //some code
    foo();
}
Followed by some code which calls bar(). foo() is never called though based on lack of alerts, and I'm not sure what's quite wrong here.

Adolf Hitler
Feb 12, 2003
Does everything else execute? I'd do a before/after alert box. You can also have foo() return a value and use that in an alert.

Without seeing how things are included or testing it myself, I can't tell you what's wrong.

Infinite
Dec 31, 2004

Never-ending, endless, countless, unlimited, unbounded, immeasurable...
This question sounds simple, but it has been giving me problems for a while now. Hopefully someone with some experience can push me in the right direction. I have been working on writing a short script to use in Google Sketchup (which lets me use Ruby to do this). Anyway, the script simply requires a point (in x, y and z terms) then it draws an object and moves to the next point until I stop giving it points. I use X1, Y1 and Z1 as variables to store this initial point.

I want to specify these points in a text file. For example the file would have something like:

0 0 1
0 1 0
1 0 1

Stored as data.txt (realistically it would be quite long with several hundred points and they would be more like 1.275 89.4 90.324). I would get these points from an excel sheet.

I want ruby to open this text file and set X1, Y1 and Z1 = the first three values (which may be something other than nice whole numbers). Then I will draw my object using that point and start again with the values from the next line. I would want this to stop when every line in the text file has been read.

Seems simple, but I’m finding understanding the io commands for Ruby to be very confusing. This is my first time ever using Ruby, and I’ve always been a novice programmer at best. Does anyone have any recommendations / advice?

To note I guess is that I would be perfectly fine splitting up that text file into three separate text files (with the same number of lines), one for each variable. I tried this but I couldn’t get Ruby to read the lines properly. I’m hoping someone can just point me on the right path and I will be able to expand on this and make sense of all of the tutorials that have been confusing me.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
That's more suited for the general programming questions thread, buuuuut:
code:
File.open('data.txt').each_line {|line|
  (x,y,z) = line.split(' ').map(&:to_f)
  p "x = #{x}, y = #{y}, z = #{z}"
}
Basically, this loops over each line, splits it apart at the spaces, then maps (changes) each of the values to the numeric value. Doing (variable, variable) is a way of assigning values from an array. The whole thing is just a more compact version of
code:
File.open('data.txt').each_line {|line|
  values = line.split(' ')
  x = values[0].to_f
  y = values[1].to_f
  z = values[2].to_f
  p "x = #{x}, y = #{y}, z = #{z}"
}
Hope that helps.

Anyway.

RailsChat time! I think bc2c4a45959be21e6314fba7876b32c1f04cd08a, a commit from the 2.3 branch that hasn't been merged into the 3.0pre branch yet, has badly broken something with cache_classes=false running on mongrel. I spent a nice chunk of my day tracking it down and am just about to sit down and try and write a test case for it. Somehow. Bleh.

Adolf Hitler
Feb 12, 2003
Well, I'd perhaps do:

code:
infile = File.new("file.name", "r")

infile.each do |line|
  if x_0.nil?
    x_0, y_0, z_0 = line.split("\s")
  end

  x, y, z = line.split("\s")

  # do stuff..
end
did a quick change

Adolf Hitler fucked around with this message at 02:04 on Jul 24, 2009

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
Oh duh, I spaced out and forgot about the initial point. Sorry dude.

Infinite
Dec 31, 2004

Never-ending, endless, countless, unlimited, unbounded, immeasurable...
Thanks to both of you. I ended up getting it working (with a tiny amount of trial and error... I didn’t realize I would have to put in the full path to the file name) using the second method dustgun showed.

Anyway, that is tremendously helpful, thanks! I’m not sure why all of the tutorials were so confusing.

Pardot
Jul 25, 2001




If you make your file a little more structured, like say this yaml here:

code:
- [3, 5, 6]
- [3, 5, 2]
- [3.234234, 235235.2234, 67]
Then you can just do this
code:
>> File.open("numbers.yml") {|f| YAML::load f}
=> [[3, 5, 6], [3, 5, 2], [3.23423, 235235.2234, 67]]

dustgun posted:

RailsChat time! I think bc2c4a45959be21e6314fba7876b32c1f04cd08a, a commit from the 2.3 branch that hasn't been merged into the 3.0pre branch yet, has badly broken something with cache_classes=false running on mongrel. I spent a nice chunk of my day tracking it down and am just about to sit down and try and write a test case for it. Somehow. Bleh.

Tracking the commit down would have been a fun use of git bisect. I've only had to use it once, but it was neat.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
I did use git-bisect for it (and it was super neat). I had thought it was a problem we hadn't caught with our code, so I didn't bother checking rails until late in the day. Oops.

dustgun fucked around with this message at 15:24 on Jul 24, 2009

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys
long-shot, but does anybody happen to have one of those 50% off coupons for Jetbrains' RubyMine that they were giving away during beta? If so, would you be willing to part with it?

Magicmat
Aug 14, 2000

I've got the worst fucking attorneys
Also, while I'm here, what is the most recommended Ruby interpreter to deploy? I know Ruby Enterprise Edition is supposed to be 1.8.6 but not suck so much, but 1.9.1 is supposed to be hella fast, and Rails just got updated for it. However, I also know that other items apparently don't yet support Ruby 1.9. Assuming I'm not using a whole pile of weird plug-ins and gems, is there anything in the standard Rails ecosystem or commonly used 3rd party code/plug-ins that does not like 1.9? I've also seen good speed results from JRuby (which apparently Rails also supports, I think?) Same questions there, too.

Adolf Hitler
Feb 12, 2003
Are there any opinions on gem creation tools? There's a half dozen right now.. and whenever I commit to something, I realize half-way through that something else was a better idea. So... opinions?

I'm going to be starting up an ETL project, since:

a) ActiveWarehouse-ETL seems virtually dead

and

b) ActiveWarehouse-ETL does not work unless your input file is perfect (or you create a hackish class to kinda sorta do it right)

also

c) It does lots of annoying things and has really, really lovely documentation


So I plan to re-write it, with planned enhancements to improve flexibility. Any suggestions for how I should proceed with this?

Adolf Hitler fucked around with this message at 02:28 on Jul 25, 2009

darqness
Jul 20, 2006

Magicmat posted:

Also, while I'm here, what is the most recommended Ruby interpreter to deploy? I know Ruby Enterprise Edition is supposed to be 1.8.6 but not suck so much, but 1.9.1 is supposed to be hella fast, and Rails just got updated for it. However, I also know that other items apparently don't yet support Ruby 1.9. Assuming I'm not using a whole pile of weird plug-ins and gems, is there anything in the standard Rails ecosystem or commonly used 3rd party code/plug-ins that does not like 1.9? I've also seen good speed results from JRuby (which apparently Rails also supports, I think?) Same questions there, too.

The biggest problem my company had converting to 1.9 was PDF writer. I know about prawn but the boss thinks it will be too much effort switching over.

NotShadowStar
Sep 20, 2000

Magicmat posted:

Also, while I'm here, what is the most recommended Ruby interpreter to deploy? I know Ruby Enterprise Edition is supposed to be 1.8.6 but not suck so much, but 1.9.1 is supposed to be hella fast, and Rails just got updated for it. However, I also know that other items apparently don't yet support Ruby 1.9. Assuming I'm not using a whole pile of weird plug-ins and gems, is there anything in the standard Rails ecosystem or commonly used 3rd party code/plug-ins that does not like 1.9? I've also seen good speed results from JRuby (which apparently Rails also supports, I think?) Same questions there, too.

Rails 2.3 is finally 100% working for 1.9.1. A lot of the common gems work for 1.9.1 without issue. A big one is Mongrel almost works but it require a find/replace in the C file and then you're good to go.

Some use JRuby for production servers and I guess it'd be neat to latch onto existing Java libraries if you have the need, but the startup time is atrocious being the JVM and all. It would not be fun to develop on. Also when you're using JRuby there needs to be JRuby specific gems versions if the original gem is C-based.

wunderbread384
Jun 24, 2004
America's favorite bread

NotShadowStar posted:

Some use JRuby for production servers and I guess it'd be neat to latch onto existing Java libraries if you have the need, but the startup time is atrocious being the JVM and all. It would not be fun to develop on. Also when you're using JRuby there needs to be JRuby specific gems versions if the original gem is C-based.

I've been using JRuby for both production and development and the startup time isn't as terrible as you think. Running tests is definitely slower than on MRI, but autotest makes it pretty bearable by skipping the double startup you need to run the rake test tasks.

Also with JRuby 1.3.0 Nailgun is integrated, which means that you run one JVM persistently in the background and any time you use JRuby it'll just farm out to that, nearly eliminating the startup speed problem. To be honest I haven't found the slower startup speed enough of an issue to try it, but it seems pretty sweet.

My biggest problem with JRuby has been the gem incompatibilities you mentioned. And it isn't so much just the native gems, it's also any gems that have dependencies on native gems, which can branch out way farther than you think. Depending on what you're doing this could be more trouble than it's worth, but on the other hand using existing Java libraries is pretty awesome (I'm using CXF for SOAP, some XML parsers, Apache POI, and a graphing library at the moment).

Lumi
Apr 26, 2006
I watched the sky.

Adolf Hitler posted:

Does everything else execute? I'd do a before/after alert box. You can also have foo() return a value and use that in an alert.

Without seeing how things are included or testing it myself, I can't tell you what's wrong.

I figured out what's wrong, it was a .yml file which inserted the IP of the server for the full path of application.js, and after my modem reset itself, I got a different IP and since I was running locally the IP changed as well and it couldn't find the js file. Everything else worked though, which was weird. Stupid error anyhow.

I've another problem now. :( If anyone has any experience with RadRails, I couldn't get the rake tasks list showing up. It was working previously. I've googled and my problems are not that 1) I didn't click refresh, 2) I don't have a rakefile in my project, 3) or did/did not set a value in the rake path. If anyone can help me it'd be much appreciated, it's pretty aggravating.

Edit: Apparently it's not recognizing that I have a Rakefile since it says it can't find it if I try running the rake from console. Is there any file changes that might affect that? This is hooked up to a source control so there may be other people's code changes that might affect this.

Lumi fucked around with this message at 13:25 on Jul 27, 2009

NotShadowStar
Sep 20, 2000
The Rails team is doing a big bug smash push this weekend. Lots of help needed!

http://weblog.rubyonrails.org/2009/7/28/rails-bugmash

HIERARCHY OF WEEDZ
Aug 1, 2005

NotShadowStar posted:

The Rails team is doing a big bug smash push this weekend. Lots of help needed!

http://weblog.rubyonrails.org/2009/7/28/rails-bugmash

I can't wait to see the results of this. I love it when good software gets better in leaps and bounds because of the community's passion. Wish I had the chops to contribute.

Operation Atlas
Dec 17, 2003

Bliss Can Be Bought
Upgraded a Merb app that uses a custom Couchdb adapter to 1.9.1 and it was fairly easy. Only two or three fixes were necessary. It gave me a chance to clean up my gem situation, so now almost everything is vendored- my only system gems are rake, fastthread and passenger. Overall I'm pretty happy with it- ordered hashes are great, and I think I'm going to like the new hash syntax. I haven't delved into many of the other changes.

Speed-wise I really can't see a difference. My test suite runs in the exact same amount of time- ~0.8 seconds for unit and ~5.4 seconds for functional. I thought it would cut it down by like 20% but the difference is negligible if it is even faster at all. I suppose most of the time in tests is IO (database, etc), so I don't think there would be much difference regardless of the language.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Not really a question I just wanted to say the anticipation for Rails 3 release is killing me.

NotShadowStar
Sep 20, 2000

Panic! at the Fist Jab posted:

I can't wait to see the results of this. I love it when good software gets better in leaps and bounds because of the community's passion. Wish I had the chops to contribute.

You don't have to be sufficient to work on the core. You can do other things to, combing Lighthouse and merging duplicate tickets, highlighting and merging duplicate patches on github, matching Lighthouse tickets with github patches and so forth!

Operation Atlas posted:

Upgraded a Merb app that uses a custom Couchdb adapter to 1.9.1 and it was fairly easy. Only two or three fixes were necessary. It gave me a chance to clean up my gem situation, so now almost everything is vendored- my only system gems are rake, fastthread and passenger. Overall I'm pretty happy with it- ordered hashes are great, and I think I'm going to like the new hash syntax. I haven't delved into many of the other changes.

Speed-wise I really can't see a difference. My test suite runs in the exact same amount of time- ~0.8 seconds for unit and ~5.4 seconds for functional. I thought it would cut it down by like 20% but the difference is negligible if it is even faster at all. I suppose most of the time in tests is IO (database, etc), so I don't think there would be much difference regardless of the language.

There's a lot of people on the RUBY IS SLOW GOD THIS LANGUAGE SUCKS* for some reason but with today's CPUs execution speed is rarely the problem. I wish the Yellowpages.com guys would put up their presentation from Railsconf the other year but they said that the Rails request chain was actually not a problem using 1.8.7, it was actually the Oracle DB couldn't handle the amount of requests and was stalling out so they had to cluster and round robin Oracle.

*from Perl-head colleagues. It's true, Perl is hella fast but it's so hard to figure out what it's doing and the same perl-heads would tell me 'don't worry about what it's doing just do it'. So I did a comparison project for genome sequence alignment in Perl and Ruby. I just did it straight up, load a genome into memory and then create hash blocks. I could never get it to work with Perl, it would eat about 10gb memory then crash. Ruby used size of genome string + (size of genome string / 31) bytes of memory and happily did what I wanted. 1.8.7 was really dog slow, lik several minutes to finish whereas 1.9.1 does it in less than a minute.

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!
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.

Lamont Cranston
Sep 1, 2006

how do i shot foam

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.

Just as a suggestion (and someone please correct me if I'm out of date here), you should stick with ruby 1.8.7 for now. Rails is quickly being converted for use on 1.9 but it's not quite there yet.

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!

Lamont Cranston posted:

Just as a suggestion (and someone please correct me if I'm out of date here), you should stick with ruby 1.8.7 for now. Rails is quickly being converted for use on 1.9 but it's not quite there yet.

Yeah, you're not the first to tell me that, thanks though :). Only reason I got 1.9 at all was that that's what Synaptic defaulted to when I told it to get "ruby".

I tried uninstalling 1.9 (purge) and installing 1.8, but got the exact same behavior. apt-get told me that it installed successfully, synaptic said it was in /usr/bin/ruby or wherever, but that directory didn't exist.

Oh well, new distro is on there so I'll try fresh.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
I used to be that way, but after a few years I feel like I can reliably install things on linux :(

edit: sometimes.

dustgun fucked around with this message at 23:39 on Aug 18, 2009

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!
Installed Mint and just used apt-get to install everything (1.8 flavors) and it's working. Installing rails as we speak.

Sewer Adventure
Aug 25, 2004
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.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
Assuming you don't want it in the db as anything other than a cache, you'll probably want fragment caching. I haven't used it, but I believe the usage is just
code:
<% cache('name', :expires_in => 60) do %>
  <%= render :partial => "menu" %>
<% end %>
along with
code:
ActionController::Base.cache_store = :file_store, "/path/to/cache/directory"

in your config

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!

Myrddin Emrys posted:

Installed Mint and just used apt-get to install everything (1.8 flavors) and it's working. Installing rails as we speak.

Okay any help is appreciated. I am following the book Beginning Ruby on Rails, and I can't get past the first loving exercise. I've never had this much trouble with a programming language before.

Here's my issue. I have installed ruby, rubygems, and rails, all the versions from the book, so they should all be compatible. Doing -v for all of them, they all register and show the right versions. So far, so good.

The exercise, a hello world thing, has me doing the following:

rails hello
cd hello
ruby script/generate controller App

This last line is the part that fails, saying:
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:159: in 'require_frameworks': no such file to load - openssl (RuntimeError)
[and then a stack trace or something]

What does this mean? Why is this so freaking hard to get set up and working?

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come

Myrddin Emrys posted:

This last line is the part that fails, saying:
/usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:159: in 'require_frameworks': no such file to load - openssl (RuntimeError)
[and then a stack trace or something]

What does this mean? Why is this so freaking hard to get set up and working?
Ugh, that's not a fun issue. Is there another package for ruby available? openssl-ruby or something like that? Maybe libopenssl-ruby ?

Adbot
ADBOT LOVES YOU

Myrddin Emrys
Jul 3, 2003

Ho ho ho, Pac-man!

dustgun posted:

Ugh, that's not a fun issue. Is there another package for ruby available? openssl-ruby or something like that? Maybe libopenssl-ruby ?

Found a "libopenssl-ruby" and installed it but no dice.

This has just been a nightmare from the getgo. Other people found success in just using apt-get to get everything and then bam it works. I've been trying for two days now to get this to a state I can learn on and no go. :(

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