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
hmm yes
Dec 2, 2000
College Slice
edit: misread what you were trying to do :)

hmm yes fucked around with this message at 19:03 on Aug 15, 2007

Adbot
ADBOT LOVES YOU

hmm yes
Dec 2, 2000
College Slice
Hobo is brand new, so there is very little up to date documentation let alone an entire book. You could print off the docs from the website and reference those instead.

I have a problem that I am sure is actually really simple: I want to add up and return a total price across a m2m association. Using the generic example, I want to be able to add up the total price of all Books based on an Author.

Author
habtm :books

Book
habtm :authors
t.column "price", :integer

Can anyone help me out?

hmm yes
Dec 2, 2000
College Slice
Thanks for the replies, I've got it working :)

hmm yes
Dec 2, 2000
College Slice

shopvac4christ posted:

What's a good way to figure out which submit button on a form was clicked if all of them have the same name?

Not entirely sure if this is the solution you need, but the with action plugin lets you easily use multiple buttons within a form. You would be able to give each button it's own name.

hmm yes
Dec 2, 2000
College Slice
it goes in /public

hmm yes
Dec 2, 2000
College Slice
If you're working in textmate, you also have a bundle that lets you do most subversion commands easily. It's called by hitting ctrl+shift+a from inside a file window or by selecting a file or folder from the drawer. This makes it easy to add a new file then add it to subversion: fruit+shift+n => type name => ctrl+shift+a => 1.

hmm yes
Dec 2, 2000
College Slice
I think the reasoning is that it allows all project files to fall under one folder. Your method spreads them out--whether that is better or not is probably up to individual opinions. I like having everything in one place. Anyone who checks out the project can make changes, commit to the repo, and deploy to the webserver all from one place.

You could achieve what you want with some rake tasks, though.

hmm yes
Dec 2, 2000
College Slice
I find my helpers are generally empty, with things like this going in my model:

code:
def full_name
   self.first_name + " " + self.last_name
end
Is this something that should be a helper? What is the rule of thumb for whether something should go in the helper instead of the model?

hmm yes
Dec 2, 2000
College Slice
Bumping this so that it can get some Caverns of Cobol loving

hmm yes
Dec 2, 2000
College Slice
Just throwing an idea out there, but have you tried manually adding save?

code:
unless params[:column_image].empty?
   @section.side_column.column_image = ColumnImage.new(params[:column_image])
   @section.side_column.column_image.save
end

hmm yes
Dec 2, 2000
College Slice
I've always used

if @posts.nil? || if @posts.blank?

hmm yes
Dec 2, 2000
College Slice

spacepirate posted:

Fantastic, self explaining code right there, especially since create_or_update is not listed in the Rails API.

Yeah, that isn't exactly ideal, but it's not like this should be a problem. Your first reaction when you see something like that is:

1) search/grep for 'def create_or_update' if you're reading the source in a text editor

or

2) google 'rails create_or_update'

Both of those will net you the answer within 10 seconds, and the code is simple enough that you should know what's going on as soon as you finish reading it. No need for extra documentation there :S

code:
# File active_record/base.rb, line 2021
def create_or_update
  raise ReadOnlyRecord if readonly?
  result = new_record? ? create : update
  result != false
end

hmm yes fucked around with this message at 20:58 on Nov 20, 2007

hmm yes
Dec 2, 2000
College Slice

Nolgthorn posted:

If you use .find_by_id in place of .find, then if that .find_by_id comes up blank it will return nil instead of an error.

This thread is so great for little tidbits like this. Thanks :)

hmm yes
Dec 2, 2000
College Slice
I was about to say InstantRails, but I went to it's website and apparently it has been replaced by BitNami.

Has anyone here done batch/multiple file upload within a rails application before?

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.

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

hmm yes
Dec 2, 2000
College Slice
You could use acts_as_taggable_on which offers the same features as on_steroids and the ability to add tags based on the model (like User) and contexts (like Interests, Bookmarks, etc.). If you don't want to use contexts, you can set it to :tags and it will basically be a drop in replacement for on_steroids.

hmm yes
Dec 2, 2000
College Slice
Two quick questions:

What's the correct notation when referring to an action and the controller it came from? Something you would want to use in a changelog, or when talking over IM/Email to another person working on the project.

Does anyone have any book recommendations on getting started in testing, specifically within a rails environment? The two books I have found are 'Foundations Of Rspec' and 'Agile Testing With Ruby And Rails', but I don't know much about either.

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

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.

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

hmm yes
Dec 2, 2000
College Slice
I'm looking to contract out a rails programmer to add some manpower to some new projects.

I'm not too worried about experience as long as you know how to use rspec and have good test coverage. You'll also need to know how to use SVN. I don't need you to know how to admin a server or how to do any html/design. Even if you can only pick up 15 hours a week, I'm interested in hearing from you.

Just send me an email introducing yourself and giving me a bit of your background. While not necessary, a sample project that includes specs would help me get to know your work--even if it's just a todo list. I'll also need to know your hourly rate.

mail to: REMOVED


edit: if you don't know rspec, but you DO know test::unit, please go ahead and email me anyways. We can work something out.

hmm yes fucked around with this message at 18:11 on Apr 14, 2010

hmm yes
Dec 2, 2000
College Slice

5TonsOfFlax posted:

I made a ror webapp back in the 1.1.6 days, and that was a pretty rough learning experience. But the app itself is still going strong, so I wanted to do my next project in hobo. I have a couple of questions:
Do I have to update the old app to rails 2.0, or can I have two different apps on the same host run different versions?

I installed the latest instantrails and hobo today to see what I could do. Not much. Instantrails seems to have db set up to use sqllite by default, and when I try to use mysql, I get some dll errors. Then everything seems to connect anyway. What's with "The procedure entry point mysql_stmt_row_tell could not be located in the dynamic link library LIBMYSQL.dll"?

Hobo scaffolding seems to work, but the user stuff doesn't. "undefined method 'username'. This is in unchanged generated scaffold code.

Hobo also seems to need classic pagination, which is no longer included, and trying to install from svn://errtheblog.com/svn/plugins/classic_pagination does jack poo poo. No errors, no new files, just nothing.

What do I really need to do to get things to "just work" in the framework that's supposed to be so loving easy?

You can run multiple versions of rails on the same server without problems. If using the gem, check your environment.rb to see what gem version is required. You can install a specific version of a gem using the -v flag, I believe. You can also rake freeze your version of rails and then you don't need the gem to be installed. Freezing a gem will place it in /vendor of the rails project, and not require the actual gem to be installed on the server.

I thought instantrails was depricated? You're always going to be better off installing ruby + rubygems => gem install rails, and I suggest you try that instead of using Instantrails.

The MySQL errors: do you have the latest mysql gem installed?

I haven't used Hobo. I'd try their mailing list, though.

hmm yes
Dec 2, 2000
College Slice
Slicehost is priced pretty fairly with their lowest VPS only $20/month. If you can't afford that, you might as well just run things on localhost because I don't think anything else is available. I guess you could try Dreamhost--they are now using Passenger / mod_rails.

hmm yes
Dec 2, 2000
College Slice
I haven't read this particular PDF, but PeepCode has a Plugin Patterns doc available.

hmm yes
Dec 2, 2000
College Slice
Jumping in to say that if you haven't tried out Passenger/mod_rails... give it a go. It's pretty awesome: just create your vhost file for the application and everything works from there. No setting up mongrel clusters, no extra configuration, easily stop/start, no PID problems. Pretty straightforward to setup cap tasks of your own to do things like restart the application or disable a vhost.

hmm yes
Dec 2, 2000
College Slice
Hi! Thanks for popping in.

hmm yes fucked around with this message at 05:29 on Oct 30, 2008

hmm yes
Dec 2, 2000
College Slice
Although I've said it before in this thread, I am going to give Passenger another post of support. It is easy to setup, seems to manage memory well, lets you track performance stats. After testing it out with a single production application I moved another 5 which had been running on mongrel over to Passenger.

I also use Passenger for development, because the Passenger Preference Pane just makes setting up development environments nice and easy. Yeah, I know all I had to do before was edit hosts and create a new vhost. Meh :)

hmm yes
Dec 2, 2000
College Slice
You have to restart your server any time you change your routes file.

I don't know if there are any Rails 2.0+ friendly books that have been published recently. I really enjoyed many of the PeepCode screencasts. You're probably most interested in Rails 2 From Scratch (Part 1, Part 2). Their rSpec, Passenger, and Capistrano videos are all great too.

hmm yes
Dec 2, 2000
College Slice
Weird, I swear that when I started out with 1.6 that you had to restart your server to get the routes file to reload. That, plus comments like '# Be sure to restart your web server when you modify this file.' in environment.rb made me just assume anything in /config required a restart. I've also done a lot of work with Radiant, and any routes found in an extension require a restart in order to be found. Combine those two and I guess I learned a bad (useless?) habit.

hmm yes
Dec 2, 2000
College Slice
Do you mean MT in general, or MT specifically for Rails?

hmm yes
Dec 2, 2000
College Slice
And an unstyled div shouldn't be affecting your layout at all unless you've done something really lazy like #content div {}

hmm yes
Dec 2, 2000
College Slice

Trabisnikof posted:

In other news Passenger is awesome, but first load is slow. Sports at 11.

Yeah, this pisses me off too. I modified my PoolIdleTime to something like 3000s instead of 300s to avoid having to let the sites spin up. Not sure if there are any major drawbacks to that, I'm not aware of any.

hmm yes
Dec 2, 2000
College Slice
What is it about Capistrano that you don't like? What is preventing you from just using an alternative? Off the top of my head I can't think of what about using Passenger it is that locks you into capistrano.

hmm yes
Dec 2, 2000
College Slice
Yeah, the HAML/SASS/Blueprint/Compass combination is really fun to work with. If you have to create a smaller static site, staticmatic is pretty sweet and lets you use all of those as well. You can also setup a pretty straightforward capistrano recipe to checkout/build the site on your server too.

hmm yes
Dec 2, 2000
College Slice
Has anyone used hpricot or similar to screen scrape pages that are heavy on ajax/javascript? Right now all I am getting returned is the ol 'your browser needs to support javascript' message when I try to pull down a page.

hmm yes
Dec 2, 2000
College Slice
That's not what The Wire taught me

hmm yes
Dec 2, 2000
College Slice
Is there anything beyond the api entry for add_index that explains what an index does, how it is good, and general introductory things like that?

hmm yes
Dec 2, 2000
College Slice
Thanks to both of you, that was exactly what I was hoping to see.

Adbot
ADBOT LOVES YOU

hmm yes
Dec 2, 2000
College Slice
You could try installing and upgrading instantrails as done on this blog post. This would have the advantage of you being familiar with instantrails. Not sure I would recommend it. At least on Windows you get to use e text editor which has come a long way and is a pretty solid alternative to textmate. I wish textmate had the tree-history for undo/redo, that poo poo is the best.

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