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
ikari
May 17, 2003

Yeah, pretty much.

Mr. Wynand posted:

sooner or later an if RAILS_ENV=="development" is going to slip in your code somewhere...

code:
module RailsPatches
  module EnvironmentSettings
    
    def environment
      RAILS_ENV
    end
    
    %w[development test production].each do |env|
      define_method("#{env}?") { environment == env}
    end

  end
end

Rails.extend(RailsPatches::EnvironmentSettings)

>> Rails.development?
=> true

In the case that you absolutely positively unfortunately must do something like that, it reads a lot nicer and will be less of a pain if the RAILS_ENV constant is ever deprecated :)

Adbot
ADBOT LOVES YOU

ikari
May 17, 2003

Yeah, pretty much.

Mr. Wynand posted:

RAILS_ENV should get deprecated and the above should be made the default. Until then you wouldn't be able to do it without breaking plugins.

At work we just made our own little loader script that loads a separate database.yml, and runs different test/env/prod configs for each developer and/or deploy target.

That actually works very well for us, but the way envs work out of the box is pretty sucky.

Yeah. The nice thing is that for a while now, database.yml has been run through ERB before being parsed. So using aliases, anchors, and mappings in YAML plus reading in other files by breaking out into ERB, you can actually do a lot of clever things with database.yml alone.

ikari
May 17, 2003

Yeah, pretty much.

Hop Pocket posted:

A question on rollbacks using capistrano. I have about 15 migrations in my source code, and I decided to change migration #7 to change the column names of a model object. On my development machine, I simply rake'd it back and then forward again:

$ rake db:migration VERSION=6
$ rake db:migrate

I then committed my code. How then to do the same through capistrano for the production host?

$ cap deploy:migrations VERSION=6

Did not work. It simply ran the migrations as if I had run

$ cap deploy:migrations

Ideas?

The rule we follow on my team is that once a migration has been committed to SVN you should rarely go back and modify it to do things like change the column names. Between the time you committed and the time you decide to modify it, it could have been rolled out to testing, staging, and then production, not to mention other developer's machines. Unless there's a real good reason for doing otherwise, just add a new migration that alters the column names.

ikari
May 17, 2003

Yeah, pretty much.

Hop Pocket posted:

This might be more of a scriptaculous question, but I can't seem to get my animations that my RJS template return to execute serially. In other words, they seem to always run at the same time. Is there a way to get any visual_effect to run only after the previous one has finished?

Grob posted:

If you're coding in pure javascript, Scriptaculous allows you to execute events once the animation has finished, however there is no API for doing this in RJS.

http://wiki.script.aculo.us/scriptaculous/show/EffectQueues

You can use EffectQueues to get that behaviour, they can sometimes behave strangely but it's likely what you want.

ikari
May 17, 2003

Yeah, pretty much.

Grob posted:

Interesting, I didn't know effect queues were supported by RJS!

Having said that it wouldn't solve the problem I had above as updating an element isn't an animation, but it would solve the initial question :)

http://wiki.script.aculo.us/scriptaculous/show/EffectsTreasureChest

Check the Effect.QueueThis section, it may be what you're looking for. I haven't used it myself but it looks like it'll let you queue up an arbitrary function.

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.

ikari
May 17, 2003

Yeah, pretty much.

Hop Pocket posted:

code:
site.com: ~/web/rails/current $ rake RAILS_ENV=production  db:migrate
(in /home/site.com/web/rails/releases/20071228132919)
/opt/csw//lib/ruby/gems/1.8/gems/activerecord-1.15.5/lib/active_record/ ... 
              connection_adapters/mysql_adapter.rb:333: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-solaris2.11]

Abort (core dumped)
site.com: ~/web/rails/current $ ll
Unfortunately, I don't know how to deal with coredumps. The place where it is segfaulting in mysql_adapter.rb is:

code:
        execute("SHOW KEYS FROM #{table_name}", name).each do |row| .... end
So it seems that it is taking issue with the SQL command. However, the rest of the rails install works perfectly, including the normal database interaction. Any ideas on how to fix this?

Reinstaling the MySQL gem could be worth a shot.

Adbot
ADBOT LOVES YOU

ikari
May 17, 2003

Yeah, pretty much.

atastypie posted:

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.

I like ControllerName#Action myself. Like SessionsController#create. It's kind of standard notation for describing an instance method of a class or module.

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