Search Amazon.com:
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 $3,400 per month for bandwidth bills alone, and since we don't believe in shoving popup ads to our registered users, we try to make the money back through forum registrations.
  • Post
  • Reply
Unixmonkey
Jul 3, 2002


Hop Pocket posted:

ERROR: While executing gem ... (ArgumentError)
install directory "/opt/csw//lib/ruby/gems/1.8/gems/mysql-2.7" not absolute

That doesn't look like a proper path. note the '//' after /opt/csw/

Adbot
ADBOT LOVES YOU

Unixmonkey
Jul 3, 2002


Begby posted:

Thank you for the info.

I do already have all the relationships and the migrations and such setup. I just wasn't sure if there was just some conventionalized way to setup editing relationships within the framework.

Typically I would just edit a movie, get a list of all the categories in a drop down, then you would select one. I think that is probably exactly what I need to do.

Check out James Golick's Attribute_fu, or at least watch Ryan Bates' screencasts on multi-model forms.

http://jamesgolick.com/attribute_fu
http://railscasts.com/episodes/73

In fact, do both, but in reverse order. You'll get a better idea of what's going on in the background.

Unixmonkey
Jul 3, 2002


skidooer posted:

I don't think you need a core guy for something so simple.

code:
class Foo < ActiveRecord::Base
  before_create :set_id
  
  def set_id
    self.id = rand(9999)
  end
end

This is bad because eventually it will randomize to an existing id and go boom.

code:
class Foo < ActiveRecord::Base
  before_create :set_id
  
  def set_id
    identifier = rand(9999)
    until Foo.find_by_id(identifier).nil?
      identifier = rand(9999)  
    end
    self.id = identifier
  end
end
Untested, but you get the idea. If an existing record has the id you generated, it generates a new one until it finds one that doesn't match. When you get close to 9,999 records, this will become expensive to run while the system searches for unused id's.

Concurrency may not be a problem in your app, but this also opens it up for a race condition where you check for an id and not find it and try to set the id, but another process used up that id in the split second before you save. (more likely when the pool of available ids grows slim) I'm not saying it wrong to do something like this (I do something similar in one of my apps), but there are reasons why auto-incrementing id's are good.

Unixmonkey
Jul 3, 2002


Physical posted:

Do you guys have any preferred gems for versioning/change logs? Stuff like this for example https://github.com/airblade/paper_trail

I use vestal_versions https://github.com/laserlemon/vestal_versions, and like it.

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