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
SpaceNinja
Jul 24, 2002

by DocEvil
This may seem like a stupid question, but how do I correctly configure database.yml? I am giving RoR development under Windows a shot, and previously I recall that the only bit of configuration I had to do was set my password to access MySQL. Now all I get is this as the default:
code:
# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  timeout: 5000

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  timeout: 5000
Am I just being incredibly dense and missing something here? Or has this changed with Rails 2.0?

Adbot
ADBOT LOVES YOU

HIERARCHY OF WEEDZ
Aug 1, 2005

SpaceNinja posted:

This may seem like a stupid question, but how do I correctly configure database.yml? I am giving RoR development under Windows a shot, and previously I recall that the only bit of configuration I had to do was set my password to access MySQL. Now all I get is this as the default:
code:
# SQLite version 3.x
#   gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
  adapter: sqlite3
  database: db/development.sqlite3
  timeout: 5000

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  timeout: 5000
Am I just being incredibly dense and missing something here? Or has this changed with Rails 2.0?


Call rails with '-d mysql' now. I think this is a bug, because just calling rails says that mysql is the default database, but we're ending up with a sqlite configuration.

SpaceNinja
Jul 24, 2002

by DocEvil

shopvac4christ posted:

Call rails with '-d mysql' now. I think this is a bug, because just calling rails says that mysql is the default database, but we're ending up with a sqlite configuration.
Ah, okay. I'm glad it's not just me, then.

Thoom
Jan 12, 2004

LUIGI SMASH!

shopvac4christ posted:

Call rails with '-d mysql' now. I think this is a bug, because just calling rails says that mysql is the default database, but we're ending up with a sqlite configuration.

Not a bug, it's the new default, mainly because it's easier to set up. Also, sqlite3 is installed by default on Mac OS X, which a whole lot of rails developers use.

HIERARCHY OF WEEDZ
Aug 1, 2005

Thoom posted:

Not a bug, it's the new default, mainly because it's easier to set up. Also, sqlite3 is installed by default on Mac OS X, which a whole lot of rails developers use.

Then there's a bug in the documentation:
code:
    -d, --database=name              Preconfigure for selected database (options: mysql/oracle/postgresql/sqlite2/sqlite3).
                                     Default: mysql

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
What hosts are you internet dudes using for your rails stuff?

Hop Pocket
Sep 23, 2003

dustgun posted:

What hosts are you internet dudes using for your rails stuff?

I'm using Joyent. I don't have a good frame of reference, as I'm fairly new to Rails and that particular world, but I will say that I have found their support to be really helpful and responsive.

hmm yes
Dec 2, 2000
College Slice
I'm using railsmachine, who are a VPS host specialized around rails. They have a gem (called railsmachine) that makes it super quick and easy to deploy using capistrano--it is literally less than 5 minutes to run everything your first time though, even if you've never used capistrano or svn before. The few support issues I've had have had quick responses. I've even sent some non hosting related questions and gotten responses :) I would recommend looking into them if you want to have your own server to maintain at a reasonable price.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
It's just all so expensive for something that I'm not sure will last :(

Hop Pocket posted:

I'm using Joyent. I don't have a good frame of reference, as I'm fairly new to Rails and that particular world, but I will say that I have found their support to be really helpful and responsive.
How flexible are they with upgrading bandwidth once you're a customer? I'm pushing around 10GB a day right now, going up around 1.5GB a week (nearly all of which are images I could probably keep on dreamhost, or toss on S3 or something I guess). I also do image processing in 1080p a dozen or so times a day, so, I'm sort of wondering how their CPU bursting stuff works. Do you get charged for it? Is this is just something I should email about?

Railsmachine looks to be way out of my price range right now, at any rate.

jonnii
Dec 29, 2002
god dances in the face of the jews
i use slicehost and apisnetworks. both are great rails hosts.

Austria
Oct 16, 2006

I'm using Media Temple and Slicehost.

Media Temple is certainly nothing worth writing home about and are great if you're looking for a premium host for your e-mail and Typo installation.

Slicehost has been amazing. I think they still have a waiting queue for new sign-ups, but once you're in the service and support offered by all the guys is great. Plenty of help from the community and lots of stuff to help you set up a Ruby on Rails stack with them quickly.

Unless you're going with Joyent's Accelerator, stay far away from them. They're formerly known as TextDrive, and while being the official Ruby on Rails host, they have terrible service and support.

jonnii
Dec 29, 2002
god dances in the face of the jews
By the way, i have a slicehost account that is barely used, so if anyone has any interesting rails projects they'd like to host let me know via PM or email (me at jonnii dot com) and i'll possibly host it for you for free.

hmm yes
Dec 2, 2000
College Slice

dustgun posted:

Railsmachine looks to be way out of my price range right now, at any rate.

This caught me by surprise because when I was looking for hosting a year+ ago it was a fairly cheap VPS. Thinking back I believe slicehost had a 3+ month wait for hosting, which may be why I never went with them in the first place. Right now I'm paying $55/month MORE than a comparable server at slicehost, which kind of sucks.

The major advantage with railsmachine is that you can hit the floor running, as the server is preconfigured with rails, apache, mongrel, etc. The railsmachine gem is awesome as well and makes it easy to deploy any number of applications. Slicehost can sort of match this using deprec (cap install_rails_stack) but I don't have any experience using it. Looks like it does everything I would need, though.

Other than the the pain of moving hosts, I can't think of a reason to stick with railsmachine. I guess 'if it aint broke dont fix it' is a pretty good reason, and if there were no cost savings I wouldn't switch. However I would save just over $1000/year and that's pretty motivating.

I do still love railsmachine. Hosting with them has been awesome and I would recommend them if you don't want to deal with setting up your own rails stack. I had previously been hosting at railsplayground, and that was a shared hosting nightmare of fcgi and missing gems.

Anyone here with a slicehost account interested in a referral? Send me a PM or post in the thread and you can have it. I'll need your account email address, and you'll get a rebate on your next bill.

hmm yes fucked around with this message at 12:36 on Dec 24, 2007

jonnii
Dec 29, 2002
god dances in the face of the jews
atastypie, see my post above :D

Hop Pocket
Sep 23, 2003

dustgun posted:

It's just all so expensive for something that I'm not sure will last :(

How flexible are they with upgrading bandwidth once you're a customer? I'm pushing around 10GB a day right now, going up around 1.5GB a week (nearly all of which are images I could probably keep on dreamhost, or toss on S3 or something I guess). I also do image processing in 1080p a dozen or so times a day, so, I'm sort of wondering how their CPU bursting stuff works. Do you get charged for it? Is this is just something I should email about?

Railsmachine looks to be way out of my price range right now, at any rate.

Someone above alluded to this before, but there are two different types of Joyent accounts.. The shared hosting (which I think is called their Shared Connector / Accelerator, formerly known as Textdrive), and then the virtual dedicated hosting, aka Accelerator.

The latter gives you the ability to upgrade to more guaranteed memory / cpu / burst when necessary. No such guarantees are really given for the shared hosting.

To be honest, I have sites running on both the virtual dedicated and the shared environments. The shared environment is a bit flakey. It tends to go down more frequently than I would like. However, I don't have any such problems with the virtual dedicated server.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
Looks like I'll probably sign up for a year of the base Accelerator package on Wednesday, unless something better comes around -- $45 for what they offer isn't bad or anything, I just wish it had more bandwidth.

Austria
Oct 16, 2006

If you're after more Rails hosts and reviews check out https://www.railshostinginfo.com.

Sharrow
Aug 20, 2007

So... mediocre.
Joyent tend to push people to BingoDisk (their S3-alike) for asset hosting.

They say unlimited bandwidth, and I know that's always a loaded statement, but in my experience with TxD/Joyent I can't see them being unreasonable with it. Maybe they could clarify.

Shared Accelerators are nothing special, but standard Accelerators are awesome if you're down with Solaris.

SpaceNinja
Jul 24, 2002

by DocEvil
I've got an SQL question as it pertains to RoR. I'm reading Ruby for Rails, and this particular set of instructions has left me somewhat :psyduck:. It says:

quote:

Adding records to the database
There are numerous ways to add data to your database, including through Web forms. Here, we'll do it the clunky way: with SQL. This expedient will let us get into the middle of the stream--doing something with the data--as quickly as possible.

The SQL commands in listing 2.2, issued to the music store_development database, create a small number of records on which we can practice.
The trouble is, I'm not quite sure what exactly he means. I've created my development, test, and production databases, but none of them are store_, and I'm also uncertain what he means by "music". Here's the relevant SQL, though I'm not entirely sure it matters:
code:
INSERT INTO composers
	VALUES (1,"Johannes", "Brahams");
INSERT INTO composers VALUES
	VALUES (2,"Claude","Debussy");

INSERT INTO works
	VALUES (1,1,"Sonata for Cello and Piano in F Major");
INSERT INTO works
	VALUES (2,2,"String Quartet");

INSERT INTO editions
	VALUES (1,1,"Facsimilie", "D. Black Music House", 1998, 21.95);
INSERT INTO editions
	VALUES (2,1,"Urtext","RubyTunes, Inc.", 1977, 23.50);
INSERT INTO editions
	VALUES (3,1,"ed. Y.Matsumoto","RubyTunes, Inc.", 2001, 22.95);
INSERT INTO editions
	VALUES (4,2,"","D. Black Music House", 1995, 39.95);
INSERT INTO editions
	VALUES (5,2,"Reprint of 1894 ed.","RubyTunes Inc.", 2003, 35.95);
I'm a little stuck, and can't really progress any further in the book until I've figured out what this means. Any suggestions?

Hop Pocket
Sep 23, 2003

Does anyone know how to get the current session id? I have a filter that I'm using to audit the controller name, action name, and request parameters. I'd like to add a session id as well.

code:
audit.session_id = session.id
That seems to produce a number of sorts that increments every request. I'm looking for the long hex string like

code:
f56e3ee404151f8c0a90928723c86e5c
FWIW, I am using the ActiveRecord session store.

Ideas?

skidooer
Aug 6, 2001

Hop Pocket posted:

Does anyone know how to get the current session id?
code:
session.session_id

SpaceNinja
Jul 24, 2002

by DocEvil
Edit: nevermind

Trabisnikof
Dec 24, 2005

SpaceNinja posted:

I've got an SQL question as it pertains to RoR. I'm reading Ruby for Rails, and this particular set of instructions has left me somewhat :psyduck:. It says:

The trouble is, I'm not quite sure what exactly he means. I've created my development, test, and production databases, but none of them are store_, and I'm also uncertain what he means by "music". Here's the relevant SQL, though I'm not entirely sure it matters:
code:
INSERT INTO composers
	VALUES (1,"Johannes", "Brahams");
INSERT INTO composers VALUES
	VALUES (2,"Claude","Debussy");

INSERT INTO works
	VALUES (1,1,"Sonata for Cello and Piano in F Major");
INSERT INTO works
	VALUES (2,2,"String Quartet");

INSERT INTO editions
	VALUES (1,1,"Facsimilie", "D. Black Music House", 1998, 21.95);
INSERT INTO editions
	VALUES (2,1,"Urtext","RubyTunes, Inc.", 1977, 23.50);
INSERT INTO editions
	VALUES (3,1,"ed. Y.Matsumoto","RubyTunes, Inc.", 2001, 22.95);
INSERT INTO editions
	VALUES (4,2,"","D. Black Music House", 1995, 39.95);
INSERT INTO editions
	VALUES (5,2,"Reprint of 1894 ed.","RubyTunes Inc.", 2003, 35.95);
I'm a little stuck, and can't really progress any further in the book until I've figured out what this means. Any suggestions?

I'm guessing the store_ is just the naming scheme he is assuming you are using, e.g. your app is store, so your dbs would be store_dev, store_test, store_production or w/e. Those sql statements are just adding test data to play with.

SpaceNinja
Jul 24, 2002

by DocEvil
That's what confuses me. The naming convention that he adopted for this project and the database schema earlier in the chapter was r4rmusic1_. But assuming that this is the case, how exactly do I add the data to the database? I know how add tables and so forth from a command line by calling a SQL file (mysql -u root -p < file.sql), but how do I specify what schema to add data to?

blargle
Apr 3, 2007
I may have missed it in this thread, but does anyone know if Ruby 2.0 has addressed the performance issues? Ruby was designed initially for running short scripts and not long running processes like web servers, etc. There had been talk of some re-architecture under the hood to make it more like Perl (virtual machine, etc). I've been tracking some of the other projects like JRuby but they don't quite seem there yet.

SpaceNinja
Jul 24, 2002

by DocEvil
Ruby 2.0 isn't out yet, but from what I've read they've put a lot of effort into addressing the performance related issues.

skidooer
Aug 6, 2001

blargle posted:

I may have missed it in this thread, but does anyone know if Ruby 2.0 has addressed the performance issues?
Don't quote me because I can no longer find the source, but I seem to recall looking at some benchmarks where YARV blew PHP away.

Edit: YARV is in Ruby 1.9 by the way, whose release just happens to have been announced today.

skidooer fucked around with this message at 05:38 on Dec 26, 2007

Pardot
Jul 25, 2001




Keep in mind that 1.9 is a development release, not intended for production. Check out Ruby 1.9 right for you?

On the issue of VMs, there are a few alternate ruby VMs being worked on
http://rubini.us/ - talk at rubyconf
http://jruby.codehaus.org/
http://www.ironruby.net/

They're all a little rough around the edges, from what I hear. I admittedly haven't tried any of them. However, rubinius seems the coolest, as it tries to be written in ruby itself as much as possible.

brae
Feb 2, 2006

SpaceNinja posted:

That's what confuses me. The naming convention that he adopted for this project and the database schema earlier in the chapter was r4rmusic1_. But assuming that this is the case, how exactly do I add the data to the database? I know how add tables and so forth from a command line by calling a SQL file (mysql -u root -p < file.sql), but how do I specify what schema to add data to?

The mysql binary takes the name of a database on the command line. If you had those SQL statements in file.sql as they are in your quote:

mysql -u root -p r4music1_development < file.sql

Would add the data to the "composers" table in the r4music1_development database. In fact, if you didn't specify a database (by running the command mentioned in your post), the mysql client would barf and tell you that you didn't have a database selected unless your .sql file had a "USE <databasename>" statement or your inserts explicitly specified a database ("INSERT INTO r4music1_development.composers...").

EDIT: I'm assuming that what you mean by "schema" in your post above is "database" in the mysql sense. If you're saying the book had you create tables named like r4rmusic1_composers and now gives you example sql like "INSERT INTO composers", then you have to edit the file to have the right table names, but then your question would make less sense.

brae fucked around with this message at 02:39 on Dec 27, 2007

SpaceNinja
Jul 24, 2002

by DocEvil
Ah okay. Thanks for the help. I actually sorta muddled through it by adding a USE r4rmusic1_development to the .sql file and then ran it in the MySQL query browser. It spat out some errors about duplicate entries for some reason, but everything seemed to have worked like it should. Speaking of which, can anybody recommend a better MySQL browser under Windows? The query browser that comes with the GUI tools is frustratingly crappy.

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.
How do I check my app's compatability with Rails 2? I was under the impression that 1.2.6 would show deprecation warnings, however, uhh... where does it show them? I can't find anything in the development.log or in the command line server output.

Hammertime
May 21, 2003
stop

SeventySeven posted:

How do I check my app's compatability with Rails 2? I was under the impression that 1.2.6 would show deprecation warnings, however, uhh... where does it show them? I can't find anything in the development.log or in the command line server output.

That's a good thing sir.

It puts them to the development console/log.

Depreciation stuff includes, using Array.concat calls without brackets, and various other minor things. It's designed to be forwards compatible, so not everyone's going to get depreciation warnings. I've got a fairly large/complex system and I'm only getting 1 or 2 total.

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.
I thought stuff that has been moved to plugins (pagination, some javascript helpers which I'm using) would show deprecation warnings. They're certainly noted as such in the documentation.

Heffer
May 1, 2003

I'm a little scared that Ruby makes classes open:

code:
class Fixnum
  def hours
    self * 3600 # number of seconds in an hour
  end
  alias hour hours
end
  
# 14 hours from 00:00 January 1st
# (aka when you finally wake up ;)
Time.mktime(2006, 01, 01) + 14.hours # => Sun Jan 01 14:00:00
If I add in someones library to get their functionality, do I run the risk of them mucking up some low-level classes like Fixnum? That feels a little dangerous to me.

ikari
May 17, 2003

Yeah, pretty much.

Heffer posted:

If I add in someones library to get their functionality, do I run the risk of them mucking up some low-level classes like Fixnum? That feels a little dangerous to me.

It's more of a problem in theory than in practice. The flexibility it allows is worth the ability to blow your foot off with it.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
Like ikari said, it's more of an "in theory" thing. No one in their right mind fucks around with the low level stuff, and if someone did in a widely distributed library, there would be a hell of an uproar about how stupid they are. In practice, open classes are fantastic and make so many things so simple.

Heffer
May 1, 2003

I'm just getting into ruby on rails and I've run across two things that bug me with scaffolding:

1) ":scaffold" is now broke or removed or something with Rails 2.0. Now you are supposed to use the "./script/generate scaffold ModelName" to generate a scaffold, which works fine apart from having its syntax changed (I think). The problem with this is that every worthwhile ruby tutorial is broke on steps 1 or 2, making it hard to learn right now.

2) You have to type in every variable and variable type on the command line to have it generate those fields for the scaffold. I had a pre-existing table in the database, and the schema was already loaded into the ruby file, and then I had to painstakingly match those up with what I typed. Is there a way to get script/generate scaffold to automatically figure it out?

As I'm still picking up RoR I havent figured out how a URL is routed to a specific view. I see the default routes in routes.rb, and I see the scaffold generated commands in the controller, and the samples in routes.rb are a little sparse to understand what its actually doing. Is there a good guide to modifying routes.rb?

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

Heffer posted:

1) ":scaffold"
2) You have to type in every variable and variable type on the command line to have it generate those fields for the scaffold

1. I would just skip scaffolding. I think it's a pretty pointless feature.
2. I think it's a good idea to start using migrations, unless you are working with a legacy database, in which case I have no idea.

Routes.

If you have thed default route, /:controller/:action/:id, then if you pass in a uri like /users/show/fred, then it will call the show method on the users controller setting the :id parameter to 'fred'.

I recommend googling for named routes, and restful routes. That should help get you started.

Novo
May 13, 2003

Stercorem pro cerebro habes
Soiled Meat

SpaceNinja posted:

can anybody recommend a better MySQL browser under Windows?
I like SQLyog

Adbot
ADBOT LOVES YOU

Heffer
May 1, 2003

jonnii posted:

Routes.

If you have thed default route, /:controller/:action/:id, then if you pass in a uri like /users/show/fred, then it will call the show method on the users controller setting the :id parameter to 'fred'.

I recommend googling for named routes, and restful routes. That should help get you started.

Is there an api for the map object and what functions I can call on it? I can't seem to find an explicit api for it.

EDIT:
Is this is? http://api.rubyonrails.org/classes/ActionController/Routing/RouteSet/Mapper.html

Wheres the syntax for map.resources or map.with_options?

EDIT2:
Ruby has terrible API docs. Is there a book that will teach me Rails 2.0 or is that too new?

EDIT3:
Why is the map.resource API over in http://api.rubyonrails.org/classes/ActionController/Resources.html ? Is it a different class? Still looking for with_options.

Heffer fucked around with this message at 22:48 on Dec 28, 2007

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