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
HIERARCHY OF WEEDZ
Aug 1, 2005

Hop Pocket posted:

ferret :words:

Here's a question. No matter what gems and plugins I install, script/ferret_server never shows up for me. Instead I have to use vendor/plugins/acts_as_ferret/ferret_server. Where did that executable come from for you?

Adbot
ADBOT LOVES YOU

Hop Pocket
Sep 23, 2003

shopvac4christ posted:

Here's a question. No matter what gems and plugins I install, script/ferret_server never shows up for me. Instead I have to use vendor/plugins/acts_as_ferret/ferret_server. Where did that executable come from for you?

Honestly I'm not quite sure. I *think* that I followed this tutorial:

http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial

And somehow ended up there. On my system, those two scripts are identical.

MrSaturn
Sep 8, 2004

Go ahead, laugh. They all laugh at first...

Austria posted:

DreamHost is a terrible Rails host.
horay =/

I guess what I want to know is how do I set up my .htaccess to default to that running application... if I point to public/dispatch.fcgi nothing ever loads.

Pardot
Jul 25, 2001




I've used acts_as_solr before. What's the difference between ferret ad acts_as_solr? They both use lucene if I'm not mistaken.

MrSaturn posted:

horay =/

I guess what I want to know is how do I set up my .htaccess to default to that running application... if I point to public/dispatch.fcgi nothing ever loads.

code:
RewriteEngine On
RewriteRule ^(.*)$ [url]http://127.0.0.1:some_port/[/url]$1 [P,L]
Then have a mongrel running at some_port. Don't use fcgi.

edit: They don't let you install gems?

Pardot fucked around with this message at 06:38 on Jan 9, 2008

MrSaturn
Sep 8, 2004

Go ahead, laugh. They all laugh at first...

Anal Wink posted:

I've used acts_as_solr before. What's the difference between ferret ad acts_as_solr? They both use lucene if I'm not mistaken.


code:
RewriteEngine On
RewriteRule ^(.*)$ [url]http://127.0.0.1:some_port/[/url]$1 [P,L]
Then have a mongrel running at some_port. Don't use fcgi.

problem is, mongrel isn't an installed gem, and they didn't allow me to run a daemon task with just ruby script/server -d, I don't think it'll work with mongrel either...

Austria
Oct 16, 2006

Your only real options with DreamHost is to use either CGI or FastCGI. Their wiki and knowledge base have a decent enough guide on how to set it up. I've only ever really set up Typo on there and that was using Capistrano.

hmm yes
Dec 2, 2000
College Slice
So an application that was getting heavy use today started throwing out a bunch of:

NoMethodError (undefined method `[]' for nil:NilClass):

On random places. I've never had these before, and generally the actions that would spit out the error would work fine if you just tried it again. Is this something that can be attributed to low memory? I've killed some other processes just in case. If this is low memory, what are some of the basic things I can do to optimize (in rails) and keep an eye on utilization (in linux)?

Edit: I'm also only running a single mongrel instance. Does it need to be two or more?

hmm yes fucked around with this message at 23:33 on Jan 8, 2008

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
With dreamhost and fastcgi, you learn about rails optimizations really fast. I recommend everyone do it once.

Vulture Culture
Jul 14, 2003

I was never enjoying it. I only eat it for the nutrients.

atastypie posted:

So an application that was getting heavy use today started throwing out a bunch of:

NoMethodError (undefined method `[]' for nil:NilClass):

On random places. I've never had these before, and generally the actions that would spit out the error would work fine if you just tried it again. Is this something that can be attributed to low memory? I've killed some other processes just in case. If this is low memory, what are some of the basic things I can do to optimize (in rails) and keep an eye on utilization (in linux)?

Edit: I'm also only running a single mongrel instance. Does it need to be two or more?
This usually happens when you have a parse error somewhere, someplace in your code. They're a total bitch to track down.

drjrock_obgyn
Oct 11, 2003

once i started putting pebbles in her vagina, there was no going back

Anal Wink posted:

I've used acts_as_solr before. What's the difference between ferret ad acts_as_solr? They both use lucene if I'm not mistaken.

Ferret is lucene written in ruby, solr is written in Java. I'd say to stick with solr or sphinx for full text search. Funny story about that. I was at the Rails Edge conference sitting next to Ezra and asked him what he thought of Ferret. He said it was great for development but once you get to more traffic it tends to buckle. Fifteen minutes later I get an emergency "our site is down" email from the clients for whom I just deployed a ferret based solution. I've heard a bunch of reports about people deploying ferret, though, so take that with a grain of salt.

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.
Anyone have any more rails host recommendations?

canned from the band
Sep 13, 2007

I'm a man of intensity. Of cool, and youth, and passionately

SeventySeven posted:

Anyone have any more rails host recommendations?

I'm considering using Media Temple. Anyone have any experience with them? From what I've read they sound alright, lots of features and not too pricey.

Hop Pocket
Sep 23, 2003

I'm storing images in my rails app for reasons that probably can't change. I've heard that send_data and send_file can cause memory issues that will stay around in mongrel. What I'd really like to do is to write out the images to disk the first time they are requested, resulting in Apache serving them each time afterwards. Is there a good best practice for this? I'll be running multiple mongrels in production, so I'd be a little concerned about concurrent processes writing out the same images to disk at the same time.

edit: I tried caches_page, but that seems to not remember the mime_type of the original response, resulting in my cached images being sent back in a text/html typed response :(

edit: I also tried caches_action, but that seems to ignore response headers (Expires, Last-Modified) that I set in a filter that runs before that action for some reason.

Hop Pocket fucked around with this message at 16:35 on Jan 11, 2008

Austria
Oct 16, 2006

B1axident posted:

I'm considering using Media Temple. Anyone have any experience with them? From what I've read they sound alright, lots of features and not too pricey.

Assuming it's (gs), you'll hate it for Rails. I currently use it to host my email and PHP and Perl applications. It's great for this. It's performance for Rails isn't that bad, compared to most shared environments, since it uses Mongrel. Configuration and stability isn't the most reliable though. It's been enough of a headache that both myself and other people I know have left it for VPS, dedicated or EC2 hosting.

If you're not too scared to set up or learn to set up your own installation of Linux, I REALLY suggest getting a VPS. Rails on shared hosting is definitely not fun. DHH's latest blog post mentions this too.

For VPS, I can't recommend Slicehost more than enough. They're cheaper than Media Temple, especially if you're going to be hosting just Rails apps (Nginx and Thin is great!). If you'd like to use me as a referrer (it gets me $5 after you sign up for 3 months of hosting, but gets you nothing extra), PM me.

canned from the band
Sep 13, 2007

I'm a man of intensity. Of cool, and youth, and passionately

Austria posted:

For VPS, I can't recommend Slicehost more than enough. They're cheaper than Media Temple, especially if you're going to be hosting just Rails apps (Nginx and Thin is great!). If you'd like to use me as a referrer (it gets me $5 after you sign up for 3 months of hosting, but gets you nothing extra), PM me.

Just checked out Slicehost, looks pretty good. Didn't really look into VPS before as I figured it would be much more expensive that a shared environment.
Got a feeling I'll probably go with Slicehost, but I don't have PM :(

skidooer
Aug 6, 2001

Hop Pocket posted:

Is there a good best practice for this?
Write it in the public directory, under the same directory structure that your route implements.

So, if your application responds to, for example, /photos/2 -> write the file to RAILS_ROOT/public/photos/2.jpg. Apache will try to serve the file first. Only when it does not exist will it send the request up to the application.

Hop Pocket
Sep 23, 2003

skidooer posted:

Write it in the public directory, under the same directory structure that your route implements.

So, if your application responds to, for example, /photos/2 -> write the file to RAILS_ROOT/public/photos/2.jpg. Apache will try to serve the file first. Only when it does not exist will it send the request up to the application.

Thanks skidooer. I checked back here right after I figured out that I can put /images/show/35.png and it will give me 35 using params[:id], and it will also save it as /public/images/show/35.png. So by using page caching by writing out my links this way, they end up in the public directory.

I guess my fear about doing it manually was a race condition between mongrel processes trying to write the same file to the disk on first load and somehow corrupting the cached image.

atastypie posted:

Something to remember: before you deploy an updated version of your app, mv the images into a temporary location or add them to the subversion repo. Otherwise you'll overwrite the folder and lose the files.

Good point - thanks.

Hop Pocket fucked around with this message at 23:21 on Jan 11, 2008

hmm yes
Dec 2, 2000
College Slice
Something to remember: before you deploy an updated version of your app, mv the images into a temporary location or add them to the subversion repo. Otherwise you'll overwrite the folder and lose the files.

savetheclocktower
Sep 23, 2004

You wait and see, Mr. Caruthers. I will be president! I'll be the most powerful president in the history of America. And I'm gonna clean up this country!

Austria posted:

For VPS, I can't recommend Slicehost more than enough. They're cheaper than Media Temple, especially if you're going to be hosting just Rails apps (Nginx and Thin is great!). If you'd like to use me as a referrer (it gets me $5 after you sign up for 3 months of hosting, but gets you nothing extra), PM me.

Seconding Slicehost. I just moved from shared hosting to a 256MB slice and the process was ridiculously smooth. A VPS has more of a learning curve than shared hosting, since you're now in charge of everything, but I credit Slicehost's exhaustive library of HOWTOs for easing that transition. I don't run Rails apps on mine, but many others in the Slicehost community do, and they appear to love it.

drjrock_obgyn
Oct 11, 2003

once i started putting pebbles in her vagina, there was no going back

savetheclocktower posted:

Seconding Slicehost. I just moved from shared hosting to a 256MB slice and the process was ridiculously smooth. A VPS has more of a learning curve than shared hosting, since you're now in charge of everything, but I credit Slicehost's exhaustive library of HOWTOs for easing that transition. I don't run Rails apps on mine, but many others in the Slicehost community do, and they appear to love it.

Thirding Slicehost. They are the best for Rails apps unless you go with Rails Machine or Engineyard, which are both *extremely* pricey. Do not go with Media Temple for a Rails app -- you will hate life. I've had poor experience with their dv for a client and a friend of mine is in the process of moving his gs to a different host, probably slicehost.

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.
Okay, so I've just "deployed" my first application, an I thought I'd share some of the things I've learned.

1) Slicehost seems pretty reasonable so far. No initial set up issues and I've only had to reimage once so far. The guides are mostly useful too.

2) I need a better way to deploy. I'm guessing SVN + Capistrano are the way to go about this. The way I just did it was to literally copy across my entire application directory, and I ran in to the following problems:
  • I set ENV['RAILS_ENV'] ||= 'production' in environment.rb. It says do that if you can't do it the better way, but in typical Rails fashion it doesn't tell you what the better way is? :confused:
  • I went to load the DB schema using rake db:schema:load but this insisted I was still in development mode and tried to create the tables in _development. In the end I had to create that database, run rake, dump the contents, create _production and load the dump. gently caress that, I nearly tore my hair out.
  • I'm using Apache to proxy requests to a Mongrel cluster. Had to run stop/start after setting up the vhost for this, reloading doesn't work.

3) Fresh environments reveal deficiencies in my code. :)

Anyone have any other advice they can offer?

Hammertime
May 21, 2003
stop

SeventySeven posted:

I set ENV['RAILS_ENV'] ||= 'production' in environment.rb. It says do that if you can't do it the better way, but in typical Rails fashion it doesn't tell you what the better way is? :confused:

A small note, I believe the usual way (at least the one I use is morelike):

ruby script/server -e production

The same argument can be used with mongrel_start

hmm yes
Dec 2, 2000
College Slice
You can run rake tasks in production by adding 'production' before the task, like so:

rake production db:schema:load

I believe rake tasks always assume development unless you do this.


Congrats on getting your first site live. Deployment gets much easier with svn+cap and some practice.

hmm yes fucked around with this message at 08:27 on Jan 15, 2008

jonnii
Dec 29, 2002
god dances in the face of the jews
it will also follow the RAILS_ENV environment variable, so if you set that to production it should default everything to use your production database.

i would recommend moving from apache to something like nginx and also investing some time into looking at capistrano.

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.
I guess it's not going as entirely smoothly as I hoped. For some reason, the live app is working differently to the app on my dev machine. This is absolutely baffling to me since I'm using the same version of Rails and MySQL on both. Is there any logical reason for this?

I think I'm going to follow jonnii's advice because I'm getting too frustrated looking at this today, so I'll re-image tomorrow and try Nginx and Capistrano.

jonnii
Dec 29, 2002
god dances in the face of the jews
what kind of differences? why not try running your app locally in production mode.

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.

jonnii posted:

what kind of differences? why not try running your app locally in production mode.

Just did this because I can't let it go and get to bed. Part of the live app is ignoring that a field is defined as :boolean (which treated as a TINYINT(1) in MySQL). If you print it it'll just show 0 or 1, where on the dev app it'll show a nice false or true. I've also got a method to toggle it, which looks like this:

code:
  def toggle
    @item = Item.find(params[:id])
    @item.revoked = params[:value]
    @item.save
    redirect_to ...
  end
Where :value is just passed in the URL as true or false, however once again, on the dev server this is working fine but on the live server it does nothing.

What confuses me most is I've used the boolean type in another place as a very similar way, and this works fine on the live server. :confused: There's absolutely no differences in the code or DB structure these things are using - the live one is generated from the dev one.

jonnii
Dec 29, 2002
god dances in the face of the jews
are you using the same version of mysql?

jonnii
Dec 29, 2002
god dances in the face of the jews
It seems i'm having my own rails problems that i can't quite seem to figure out, and I was wondering if someone might be able to give me a hint to get this working.

I'm trying to install mephisto on my shared host (apisnetworks, great host by the way!), and it seems that my .htaccess file in my /public directory isn't forwarding the request successfully to dispatch.fcgi for some reason.

the contents of my .htaccess is:

code:
SetEnv RAILS_ENV production
RewriteBase /
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
The apache error_log doesn't show anything of interest, and all I'm getting is a directory listing not allowed message when trying to access the site.

Any ideas??

edit: turns out that I needed RewriteEngine On in there too.

jonnii fucked around with this message at 23:07 on Jan 15, 2008

SeventySeven
Jan 18, 2005
I AM A FAGGOT WHO BEGGED EXTREMITY TO CREATE AM ACCOUNT FOR ME. PLEASE PELT ME WITH ASSORTED GOODS.

jonnii posted:

are you using the same version of mysql?

Yes, 5.0.45 on both.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik
I'm a total newb to web programming in general, and I wanted to get started with Ruby on Rails, but every tutorial I read kind of comes from the assumption that a person will allready know a lot about web programming. They all have this "see with PHP it would be super hard to integrate your .xml file and your .wtf" but in rails all you do is edit Blah.rhtml, and then put a tag in your Db.yml file, and I have no idea what the gently caress any of this poo poo is.

I'm good at programming and ruby is a breeze to pick up, but lord all these web standards cause my head to spin. Is there a good tutorial about beginning web programming with Rails assuming one has never done it with anything else?

MrSaturn
Sep 8, 2004

Go ahead, laugh. They all laugh at first...

Zaxxon posted:

I'm a total newb to web programming in general, and I wanted to get started with Ruby on Rails, but every tutorial I read kind of comes from the assumption that a person will allready know a lot about web programming. They all have this "see with PHP it would be super hard to integrate your .xml file and your .wtf" but in rails all you do is edit Blah.rhtml, and then put a tag in your Db.yml file, and I have no idea what the gently caress any of this poo poo is.

I'm good at programming and ruby is a breeze to pick up, but lord all these web standards cause my head to spin. Is there a good tutorial about beginning web programming with Rails assuming one has never done it with anything else?

Well, if you're not familiar with html and css to begin with, I'd recommend you at least go through the tutorials at https://www.w3schools.org. Failing that, look up an article called "Rolling with ruby on rails". That's where I started.

Zaxxon
Feb 14, 2004

Wir Tanzen Mekanik

MrSaturn posted:

Well, if you're not familiar with html and css to begin with, I'd recommend you at least go through the tutorials at https://www.w3schools.org. Failing that, look up an article called "Rolling with ruby on rails". That's where I started.

I'm cool with html, and while I've never used css I at least know what they are and what they do. I've also read that tutorial and it seems to assume a lot (especially about setting up the database and such.) I mean it's halfway into that tutorial before he even touches ruby. I kinda thought the whole point of RoR is that you didn't have to gently caress with all the html and SQL stuff and could do it through ruby.

Hammertime
May 21, 2003
stop

Zaxxon posted:

I kinda thought the whole point of RoR is that you didn't have to gently caress with all the html and SQL stuff and could do it through ruby.

You're right about the point, that's a major part of it. The automation though is also based on having a strong familiarity with more manual/raw web development with php/python etc.

While rails removes a lot of the boiler plate code in web development, I believe you need to have the low level knowledge to use rails without shooting yourself in the foot. I might be wrong, but RoR has a sizable learning curve even after having a strong foundation in web programming (I've been a commercial web dev for 5 years, rails dev for 6ish months).

skidooer
Aug 6, 2001
Is anyone here using a document-oriented database (such as CouchDB or ThruDB) with Rails? I've got some projects where SQL isn't the right tool for the job. There are several ActiveRecord-like abstractions (which I'd like to use) on the go, but they all seem to be in the early stages. So I'm also wondering which of those projects I should be focusing my attention on, if any.

Pardot
Jul 25, 2001




There was mention of Active Couch, which is an active record wrapper for couchdb on the rails envy podcast today. I haven't used it myself, but it could be worth looking at.

skidooer
Aug 6, 2001

Pardot posted:

There was mention of Active Couch
That's for the link. That's definitely one of the more mature ones I have seen. But I'm not too keen on their API. And it doesn't look like it will even let me store hashes or arrays. Might be a good starting point for rolling my own, however.

Pardot
Jul 25, 2001




Registration for railsconf just opened up the other day. http://www.railsconf.com/

quote:

The content this year will also take a step up in terms of experience required for many sessions. Less “I’m just getting started, how does it work?” and more “I’ve been doing this for a while, how can I become better?”.

A good number of the sessions are already announced, as well as the tutorials. But the keynote names are still being pinned down. And we’re also reserving some session slots for emerging topics as we get closer to the conference.

skidooer
Aug 6, 2001
Well I went ahead and started creating yet another CouchDB library named ActiveCushion. I couldn't find one that worked the way I envisioned it, sticking to AR conventions as much as possible, so here we are. There's more work to do before it's ready for any kind of release, but I'm quite happy with the way it's shaping up.

Creating documents is not unlike doing so with ActiveRecord. There is, however, no schema. You're free to add whatever attributes you want. Validations will ensure input is sane.
code:
Person.create(:name => 'David Heinemeier Hansson', :age => 28, :aliases => %w(DHH Dave))
=> #<Person:0x2661d20 @attributes={"name"=>"David Heinemeier Hansson",
       "_rev"=>"724093250", "_id"=>"85A2D0B5E67FF94B284B3EEAA9D285D3", "type"=>"person",
       "aliases"=>["DHH", "Dave"], "age"=>28}>
CouchDB uses the concept of views for record retrieval. Javascript is the default language for creating views, and I've created a few examples in that language:
code:
all:
function(doc) {
	if (doc.type == "person") {
		map(null, doc);
	}
}

by_name:
function(doc) {
	if (doc.type == "person") {
		map(doc.name, doc);
	}
}

by_alias:
function(doc) {
	if (doc.type == "person") {
		for (var i = 0; i < doc.aliases.length; i++) {
			map(doc.aliases[i], doc);
		}
	}
}

by_age:
function(doc) {
	if (doc.type == "person") {
		map(doc.age, doc);
	}
}
To query one of those views in ActiveCushion we use the familiar find_XXX-like methods.
code:
Person.find_all # Find all records
Person.find_by_name('David Heinemeier Hansson') # Find David Heinemeier Hanssons 
Person.find_by_alias('DHH') # Finds DHH aliases
Person.find_by_age(:startkey => 30, :endkey => 50) # Find people betwen the ages of 30 and 50
And just like ActiveRecord, one can reference a document by ID. Retrieving and manipulating values in the document also share the same behaviour as ActiveRecord.
code:
person = Person.find('85A2D0B5E67FF94B284B3EEAA9D285D3')
=> #<Person:0x265a840 @attributes={"name"=>"David Heinemeier Hansson", 
       "_id"=>"85A2D0B5E67FF94B284B3EEAA9D285D3", "_rev"=>"724093250",
       "type"=>"person", "aliases"=>["DHH", "Dave"], "age"=>28}>
person.name
=> "David Heinemeier Hansson"
person.aliases 
=> ["DHH", "Dave"]
person.company = '37signals'
=> "37signals"
person.save
=> true
Because CouchDB saves each revision of the document, we can also go back in time:
code:
Person.revisions('85A2D0B5E67FF94B284B3EEAA9D285D3').map do |r|
  Person.find('85A2D0B5E67FF94B284B3EEAA9D285D3', :rev => r).company
end
=> ["37signals", nil]

skidooer fucked around with this message at 23:15 on Feb 1, 2008

Adbot
ADBOT LOVES YOU

Hop Pocket
Sep 23, 2003

I do love slicehost, but I'll be damned if gem does not work very well on a 256 slice. Very memory intensive. Installing one gem can take hours. I don't need a 512 slice, but am considering getting one just to make gem usage more palatable.

edit: 512 slice a billion times faster.

Hop Pocket fucked around with this message at 16:39 on Feb 4, 2008

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