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
canned from the band
Sep 13, 2007

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

phazer posted:

UGH, I realized what it is. I looked up how to do cropped thumbnails with attachment_fu/rmagick, and I remembered I found this, which makes you rewrite the processor code:

Crop Images using Attachment_Fu/rMagick

Not really an expert on attachment_fu, but as far as I know most people have moved over to Paperclip. Might be worth a look if you're having problems.

goodbye attachment_fu hello paperclip

Adbot
ADBOT LOVES YOU

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Is there a way to easily report at the bottom of the page on a development application the processing time, requests and speed of which the page loaded? I am getting tired of always looking over to my terminal window on every page request to see even just a summary of what's been happening.

Also another question; I understand that the development environment runs a bit differently than in production. Now that I've got my db requests more or less optimized for the time being I'm noticing that my bottleneck seems to be loading partials, for instance I am using a commenting system and each comment is a partial with another partial in it for the rating system. When there are 25 comments being loaded on the page each one loads at a speed of between 0.7-1.7ms for the rating and 1-3ms per comment, in comparison the full amount of db requests on such a complex page load maybe 0.3ms in absolute total.

Why are the partials being loaded slowly, in production are these partials just going to be in memory or something?

Thanks in advance for both questions

Nolgthorn fucked around with this message at 01:50 on Dec 29, 2008

Evil Trout
Nov 16, 2004

The evilest trout of them all

Nolgthorn posted:

Is there a way to easily report at the bottom of the page on a development application the processing time, requests and speed of which the page loaded? I am getting tired of always looking over to my terminal window on every page request to see even just a summary of what's been happening.

You might like FiveRuns Tuneup. Personally, I've tried things like this but always end up just looking at the console while optimizing.


Nolgthorn posted:

Also another question; I understand that the development environment runs a bit differently than in production. Now that I've got my db requests more or less optimized for the time being I'm noticing that my bottleneck seems to be loading partials, for instance I am using a commenting system and each comment is a partial with another partial in it for the rating system. When there are 25 comments being loaded on the page each one loads at a speed of between 0.7-1.7ms for the rating and 1-3ms per comment, in comparison the full amount of db requests on such a complex page load maybe 0.3ms in absolute total.

Why are the partials being loaded slowly, in production are these partials just going to be in memory or something?

Rails performs vastly different in production mode. Templates are cached, so if you make a change to them you have to restart the process. I have noticed performance problems with rendering too many partials in the past, but that's when there's hundreds. The overhead should be minor with 25.

You should do yourself a favor and enable production mode from time to time during development (just point your production entries in database.yml at the development database and it should work.)

Hammertime
May 21, 2003
stop

Nolgthorn posted:

Why are the partials being loaded slowly, in production are these partials just going to be in memory or something?

Thanks in advance for both questions

Partials are just never going to be really fast. They do have very different performance characteristics in development mode though, since I believe they're manually loaded from disk and parsed every time. Try turning template loading caching on manually in your environments/development.rb to get a better idea. In production these partials should sit loaded in memory.

code:
config.action_view.cache_template_loading = true
I think the times you're seeing are largely the parse times for templates as opposed to their rendering.

You're hitting against one of the most frustrating parts of working with rails. The trade off between performance and clean code structure.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Thanks you guys for your help.

I have another question that might be really simple.

Is there a way I can update a column in the database on a table that contains a field named updated_on, without having the updated_on field update?

In the old days it was possible to do:
code:
update_attribute('column', value)
This was special because it didn't fire off validations or do anything except update the column, but it seems that in the latest Rails it does do all those other things; can I get that old functionality back or what is the workaround for it?


Edit: It seems that I cannot even hack my way around it, here is my fat controller code:
code:
  def update
    verify_is_owner(@forum_thread)
    old_updated_on = @forum_thread.updated_on                       #<= Look here
    @forum_thread.attributes = params[:forum_thread]
    @first_post = @forum_thread.first_post
    @first_post.attributes = params[:first_post]
    if @first_post.valid? and @forum_thread.save
      @first_post.save
      @forum_thread.update_preview(@first_post)
      @forum_thread.update_attribute('updated_on', old_updated_on)  #<= Look here
      flash[:notice] = "Changes saved"
      redirect_to thread_path(@forum_thread)
    else
      render :action => :edit
    end
  end
It seems using update_attribute to change the 'updated_on' column will cause Rails to update the 'updated_on' column to the current time.


I may need to call the column something different if I want to have more control over it I guess.

Nolgthorn fucked around with this message at 12:05 on Dec 29, 2008

Hammertime
May 21, 2003
stop

Nolgthorn posted:

I may need to call the column something different if I want to have more control over it I guess.

Honestly, you're fighting against the tide of convention. I'd just call it something else (last_updated_at/on etc), add before filters to change the attribute automatically if you want to retain some of the behavior.

Minor code tips based on your sample:

It might be worth altering the the thread before the save call to minimize on the number of database writes, so only one save is called.

code:
if @first_post.valid? and @forum_thread.valid?
  @forum_thread.generate_preview(@first_post) # sets the internal preview variable, doesn't save
  @first_post.save!  
  @forum_thread.save!
The line "@first_post.save" is a bit funny/a code smell. It's not bad in this instance since you're checking validity immediately before, but I've found it's a good habit to never allow an unchecked .save and risk the possibility of silent failure (and the fun debugging times that ensue). If it's on a line by itself, and should pass anyway, I just use the .save! method, to ensure it's easy to track down if I've introduced a regression bug etc.

One more minor thing to think about is transactions. If you're saving more than one thing at a time, it's probably worth batching it in a transaction. This is a really unlikely circumstances, but what if the DB server died after the "@forum_thread.save" call, but before the "@first_post.save" call, you'd have invalid/inconsistent data. Not a big deal for threads/forums, but something to consider for other projects.

Operation Atlas
Dec 17, 2003

Bliss Can Be Bought

Nolgthorn posted:

code:
  def update
    verify_is_owner(@forum_thread)
    old_updated_on = @forum_thread.updated_on                       #<= Look here
    @forum_thread.attributes = params[:forum_thread]
    @first_post = @forum_thread.first_post
    @first_post.attributes = params[:first_post]
    if @first_post.valid? and @forum_thread.save
      @first_post.save
      @forum_thread.update_preview(@first_post)
      @forum_thread.update_attribute('updated_on', old_updated_on)  #<= Look here
      flash[:notice] = "Changes saved"
      redirect_to thread_path(@forum_thread)
    else
      render :action => :edit
    end
  end

Oh. Gosh. Where do I start?

First thing's first: Controllers should be skinny. Something is wrong if your controller has any logic that is concerning anything other than these things: Rendering, redirecting, security, requests, sessions or parameters. "Business logic" has absolutely no place in the controller. Get that stuff to the model, and I think you'll find a lot of the complexity will melt away by itself.

Secondly, this stuff is so much easier to test once it is in the model. You should have comprehensive unit tests built around this stuff. That way, you KNOW it works, instead of the "test and refresh" method of "testing" your code (Where you THINK that it PROBABLY works). If it doesn't work, you know exactly what is wrong.

Thirdly, fetching your @forum_thread should probably not be in a before_filter, but if it is, verify_is_owner should be called along with it. That way, by the time you get in the method body of "update" you know everything is kosher with permissions and you can just keep going.

Fourthly, you should definitely be using a different attribute name than updated_on. You're not really tracking updated_on in this case, so rename the dang thing.

Fifthly, use && instead of "and". They are NOT the same thing. They have different precedence.
code:
a = 'test'
b = nil
both = a && b       # both == nil
both = a and b      # both == 'test'
both = (a and b)    # both == nil
Sixthly, something smells when you're doing update_attributes on two different objects in the same request. I'm not exactly sure what's going on with your app, but it is unlikely that doing it this way is the best and cleanest way to solve the problem. I think I've only done that once out of the >500 actions that I've written.

I don't mean to harsh on you, but it's best that you learn these conventions as quickly as possible. It's better for you, and for anyone who might have to read your code in the future.

(Also, in response to Hammertime, I never use save!. I'm not sure if it is just preference or what, but I like if->else over begin->rescue)

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I am being honest when I say that is some of the ugliest code I have written... sigh the Internet and posting things I will regret.

The code would look a lot cleaner if 'they' at Rails core would get associated objects built all in one request, that way I could easily tuck the params[:first_post] inside of params[:forum_thread][:comment] and be done with the whole thing. I did try putting some logic in my model for this along the lines of:
code:
  def comment=(comment_attributes)
    first_post = comments.find(:first, :order => "comments.created_at")
    if first_post
      first_post.attributes = comment_attributes
    else
      comments.new(comment_attributes)
    end
  end
But I don't remember now what was going wrong with the code that I gave it up.

I have since renamed the offending column like you guys have mentioned, I don't fully know what I was thinking... something seems simple and I get further along then it's no longer any good for my purposes. I am however going to maintain that && is more or less exactly the same as 'and' for me generally because I only ever use 'if' or 'unless' statements with booleans.

Nolgthorn fucked around with this message at 17:32 on Dec 29, 2008

skidooer
Aug 6, 2001

Nolgthorn posted:

The code would look a lot cleaner if 'they' at Rails core would get associated objects built all in one request
You mean this?
code:
<% form_for :outer do |o| %>
  <% o.fields_for :inner do |i| %>
    <%= i.text_field :name %>
  <% end %>
<% end %>

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Exactly, except that it would do something once it hit the .new(params) method.

narbsy
Jun 2, 2007

Nolgthorn posted:

I am however going to maintain that && is more or less exactly the same as 'and' for me generally because I only ever use 'if' or 'unless' statements with booleans.

In Ruby, all objects are 'True' except 'False' and nil, so it doesn't really matter.

The precedence can really hurt sometimes, as it's unexpected. The 'and'/'or' versions of &&/|| have really low precedence - lower than assignment. That can get tricky... easier to just use what will behave as expected.

http://phrogz.net/ProgrammingRuby/language.html#table_18.4

skidooer
Aug 6, 2001

Nolgthorn posted:

Exactly, except that it would do something once it hit the .new(params) method.
Rails had that feature once upon a time. You might find this discussion interesting: http://groups.google.com/group/rubyonrails-core/browse_thread/thread/3c61e00916c365e5

NotShadowStar
Sep 20, 2000
Is there a cleaner way of handling the output of validation errors without monkeypatching ActionView::Base.field_error_proc ? I really don't like how it just injects html in the view when I have a nice system using the flash for displaying errors. I have this code, and it's fine:

code:
   
 @person = Person.new params[:person]
    if @person.save
      flash[:notice] = "#{@person.first_name} #{@person.last_name} was created"
      redirect_to "/admin/users"
    else
      flash[:error] = @person.errors.full_messages.collect {|m| m + "<br />"}
      render :action => 'new'
    end
But when validations fail that happens plus the html injection from field_error_proc. I could override field_error_proc and just make it return but ugh.

skidooer
Aug 6, 2001

NotShadowStar posted:

Is there a cleaner way of handling the output of validation errors without monkeypatching ActionView::Base.field_error_proc ?
ActionView::Base.field_error_proc is an accessor. You don't need to monkeypatch it. I don't see the harm in modifying it to fit your needs, it seems to be designed with that ability in mind.

NotShadowStar
Sep 20, 2000
Digging into the depths of the Rails wiki, home of abandoned and unfindable pages brings up

http://wiki.rubyonrails.com/rails/pages/HowtoChangeValidationErrorDisplay

So yeah, that works then. Use my notification system to display the errors and use the proc that's fired on validation fail to add a "FAIL" class to the errant fields.

Awesome.

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
I too don't like the way field_error_proc adds that horrible div around failing form elements, it's always messing up my layouts.

I usually make it a point to add this at the very end of my environment.rb:
code:
ActionView::Base.field_error_proc = Proc.new {|html_tag, instance| "<span class=\"field_with_errors\">#{html_tag}</span>"}
But you could probably change it to suit your needs.

Edit: As a related question is there a way to reliably return error messages on the fields from an associated model, then display them or what is the best practice for this?

Nolgthorn fucked around with this message at 15:20 on Dec 31, 2008

Evil Trout
Nov 16, 2004

The evilest trout of them all

Nolgthorn posted:

I too don't like the way field_error_proc adds that horrible div around failing form elements, it's always messing up my layouts.

Why not just use CSS to not display it as a div? If you change the div's style to have display: inline in your CSS it is basically the same thing as a span.

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 {}

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense
Usually I use paragraph tags around my form elements, then I have things on the right of it or maybe I've got a field in the middle of a sentence for some reason I dunno stuff gets messed up. True I could use display inline on the divs but why not use span though, it's nice to have the control.

Pardot
Jul 25, 2001




atastypie posted:

And an unstyled div shouldn't be affecting your layout at all unless you've done something really lazy like #content div {}

It can gently caress stuff up since a div is a block element and spans are inline. You either have to give it the inline property like evil trout said, or I actually just saw a post about it last saturday that brought this ticket and patch to my attention.

NotShadowStar
Sep 20, 2000
So next up on the list is I'm writing a model for handling experiment data. Experiments are always done on plates. Plates, in my context, are generally a 2d array that holds stuff. In a separate project I wrote a basic Plate class that's pretty much a 2d array with pretty accessors with other helper stuff, and specialized Plates for their own experiment are subclasses and add their own stuff.

Since I want to store pretty much everything in the DB as possible, I want to store all experiment data in the database with models. Problem 1) The table is going to get large by MySQL standards. I've been considering a design of each row of the database is 1 element in the 2d array, identified by columns in the table that correlate to the position and id # of the experiment plate. Right off the bat I'd be importing about 15,000 experiments, and each experiment can have up to 384 elements (more like an average of ~ 330) so bam that's ~4.95 million rows and probably grow another 1-2 million a year. That's just for one type of experiment, there will be others that will add other millions of rows in this manner to other tables. Other information systems that do something similar to what I'm doing have the same strategy, but they use higher end databases and I understand MySQL might not like this.

The other thing is since there will be several models that are similar but have different properties for different types of experiments or similar data I feel like I should be looking into writing an acts_as, but I don't know the first thing about that.

NotShadowStar fucked around with this message at 19:59 on Jan 2, 2009

Hammertime
May 21, 2003
stop

NotShadowStar posted:

So next up on the list is I'm writing a model for handling experiment data. Experiments are always done on plates. Plates, in my context, are generally a 2d array that holds stuff. In a separate project I wrote a basic Plate class that's pretty much a 2d array with pretty accessors with other helper stuff, and specialized Plates for their own experiment are subclasses and add their own stuff.

...



Firstly, 1 row per experiment is probably the right way to go (provided you don't need to pull experiments based on their results). One row per element is an extremely wasteful approach.

Secondly, if you've got various different experiment types with differing data requirements your have a couple of choices. The first is to have one table per experiment type. The second is to use RoR's single table inheritence and base multiple models around it, I'm not overly familiar with this approach, but it should be fine given you only have 15,000ish experiments.

Splitting the experiment data off into it's own table and giving it a polymorphic association back to the experiment tables is also an option.

As to how you store the data itself, I'd need a bit more information on what each element details, but storing it into a text column with a small bit of encoding is my current gut feeling.

MySQL really isn't friendly to multidimensional data.

NotShadowStar posted:

The other thing is since there will be several models that are similar but have different properties for different types of experiments or similar data I feel like I should be looking into writing an acts_as, but I don't know the first thing about that.

As an intermediary to plugin writing (as this can be a slightly tricky endeavor on your first go), perhaps just use a mixin for common functionality and include it in each of your experiment models.

Hammertime fucked around with this message at 03:54 on Jan 3, 2009

HIERARCHY OF WEEDZ
Aug 1, 2005

Is anyone using edge Rails and the latest featureset that Rails provides consistently? I stopped using Rails about a year ago and focused on microframeworks like Sinatra, and I'm wondering if there's anything really amazing that I'm missing that the switch to Rails may be worth it again. Any awesome plugins, etc...

Nolgthorn
Jan 30, 2001

The pendulum of the mind alternates between sense and nonsense

Panic! at the Fist Jab posted:

Is anyone using edge Rails and the latest featureset that Rails provides consistently? I stopped using Rails about a year ago and focused on microframeworks like Sinatra, and I'm wondering if there's anything really amazing that I'm missing that the switch to Rails may be worth it again. Any awesome plugins, etc...

No not really, I am really looking forward to Rails 3 they promise to merge Merb and hopefully we get nice little things like recursive database manipulation.

nebby
Dec 21, 2000
resident mog

Panic! at the Fist Jab posted:

Is anyone using edge Rails and the latest featureset that Rails provides consistently? I stopped using Rails about a year ago and focused on microframeworks like Sinatra, and I'm wondering if there's anything really amazing that I'm missing that the switch to Rails may be worth it again. Any awesome plugins, etc...
I have yet to bite the bullet, but running multithreaded Rails on JRuby is going to be a big win for us theoretically. (We're running JRuby now, but on Rails 2.1 with Ruby Runtime pooling.) Faster server restarts and dramatically reduced memory, since it does not have to cache the ASTs for all the gems N times.

Ghotli
Dec 31, 2005

what am art?
art am what?
what.

nebby posted:

I have yet to bite the bullet, but running multithreaded Rails on JRuby is going to be a big win for us theoretically. (We're running JRuby now, but on Rails 2.1 with Ruby Runtime pooling.) Faster server restarts and dramatically reduced memory, since it does not have to cache the ASTs for all the gems N times.

We evaluated JRuby at work for a good while but eventually scrapped it. This was a while back and I assume JRuby has matured. Can you describe your deployement method with JRuby?

skidooer
Aug 6, 2001

Panic! at the Fist Jab posted:

Is anyone using edge Rails and the latest featureset that Rails provides consistently? I stopped using Rails about a year ago and focused on microframeworks like Sinatra, and I'm wondering if there's anything really amazing that I'm missing that the switch to Rails may be worth it again. Any awesome plugins, etc...
Rails has it's own microframework now. Most changes have been evolutionary, though. You probably won't see any significant changes until 3.0.

Pardot
Jul 25, 2001




What do you guys like better: braid or git submodules? Both have been frustrating.

Operation Atlas
Dec 17, 2003

Bliss Can Be Bought

Pardot posted:

What do you guys like better: braid or git submodules? Both have been frustrating.

I gave up on submodules. I just commit everything straight into the repo. You suffer from a dirtier history, but it is so much easier to deal with and deploy.

I might try it again though. The primary reason why i gave up on it was because I was still using git-svn (for Trac), and submodules don't work at all with git-svn.

I've never used Braid... How is it different from Piston?

nebby
Dec 21, 2000
resident mog

Ghotli posted:

We evaluated JRuby at work for a good while but eventually scrapped it. This was a while back and I assume JRuby has matured. Can you describe your deployement method with JRuby?
We're on glassfish, so it's pretty straightforward. We push the code with capistrano, and then use Warbler to package things up and do a glassfish deploy. We then restart glassfish round robin via capistrano, warming them up in sequence via curl and putting them back into nginx with a shell script.

Overall, my biggest complaint with JRuby is startup time -- it sucks. I've talked with the JRuby guys about ways to improve this but I don't think its very high on the priority list. The main problem is JRuby's parser and lexer is pretty slow, and so parsing and lexing all the gems at startup time takes a significant amount of work. Multithreaded Rails will reduce this burden on the server since it only has to do this once, instead of N times for each Ruby runtime, but on the client you still end up having to wait 20-30 seconds for a script/console :(

Other than that, JRuby is rock solid, we have been using it for a few months now and being able to integrate with Java code we already had has been a huge help.

NotShadowStar
Sep 20, 2000
Okay I redefined my original problem and came up with a much better solution.

Now I'm wondering if some AR gurus can help out with this. I have this first-stab design (in migration format)

code:
class CreateSdsExperiments < ActiveRecord::Migration
  def self.up
    create_table :sds_experiments do |t|
      t.integer :experiment_id
      
      t.integer :sds_plate_id

      t.integer :stock_plate_1_id
      t.integer :stock_plate_2_id
      t.integer :stock_plate_3_id
      t.integer :stock_plate_4_id
      
      t.integer :snp_1_id
      t.integer :snp_2_id
      t.integer :snp_3_id
      t.integer :snp_4_id
      
      t.string :layout_type

      t.timestamps
    end
    
    add_index :sds_experiments, :experiment_id
    add_index :sds_experiments, :sds_plate_id
    add_index :sds_experiments, :stock_plate_1_id
    add_index :sds_experiments, :stock_plate_2_id
    add_index :sds_experiments, :stock_plate_3_id
    add_index :sds_experiments, :stock_plate_4_id
    add_index :sds_experiments, :snp_1_id
    add_index :sds_experiments, :snp_2_id
    add_index :sds_experiments, :snp_3_id
    add_index :sds_experiments, :snp_4_id
  end

  def self.down
    drop_table :sds_experiments
  end
end
Essentially an SdsExperiment is nothing more than a fuckoff join table. The interesting part is that 2 sets of fields, the stock plates and the snps should can reference one stock plate or one snp.

If I just needed one then that's easy, SdsExperiment belongs_to :stock_plate and StockPlate has_many :sds_experiments. However, I need up to 4 stock plates, and the order of them is important (I need to know what stock plate 1 is). Essentially I want to say something like belongs_to :stock_plate, :using_instance_method => :stock_plate_1. So in the end I can do something like

Experiment.find(1).sds_experiment[1].stock_plate_1.clownfarts

If this makes any sense at all...

Ghotli
Dec 31, 2005

what am art?
art am what?
what.

nebby posted:

jruby...

I assume you're using glassfish v2 since v3 isn't stable yet. At work we have a few rails applications that we need deployed at the same time. When we were looking into glassfish I remember v2 not being able to host more than one rails app at a time. Do you have any idea if this is true or not?

We also had a whole lot of trouble getting warbler to work correctly. Obviously it's stable enough now for you to use in production. Do you have capistrano create the war file on the production server? If so could you show us the code for how you did that. Also, what is your rationale for warming up the production servers with curl. Is this so you can keep the rails environment in memory?

NotShadowStar
Sep 20, 2000
Since nobody cares I'll just put this up anyway. I solved the problem of one model inheriting from another multiple times while keeping track numeric associations like this

code:
class SdsExperiment < ActiveRecord::Base
  has_one :plate_1, :class_name => 'StockPlate', :foreign_key => :plate_1_id
  has_one :plate_2, :class_name => 'StockPlate', :foreign_key => :plate_2_id
  has_one :plate_3, :class_name => 'StockPlate', :foreign_key => :plate_3_id
  has_one :plate_4, :class_name => 'StockPlate', :foreign_key => :plate_4_id
  
  has_one :snp_1, :class_name => 'Snp', :foreign_key => :snp_1_id
  has_one :snp_2, :class_name => 'Snp', :foreign_key => :snp_2_id
  has_one :snp_3, :class_name => 'Snp', :foreign_key => :snp_3_id
  has_one :snp_4, :class_name => 'Snp', :foreign_key => :snp_4_id
  
end
and that works totally fine.

Hop Pocket
Sep 23, 2003

Have you considered creating your join model with an integer :position column? Seems like that might scale a little bit better than explicitly creating column_[1,2,3,4] columns.

code:
    create_table :sds_experiments do |t|
      t.integer :experiment_id      
      t.integer :sds_plate_id

      t.integer :stock_plate_id
      t.integer :snp_id
      t.integer :position

      t.string :layout_type

      t.timestamps
    end

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
erp, nevermind.

dustgun fucked around with this message at 01:28 on Jan 24, 2009

nebby
Dec 21, 2000
resident mog

Ghotli posted:

I assume you're using glassfish v2 since v3 isn't stable yet. At work we have a few rails applications that we need deployed at the same time. When we were looking into glassfish I remember v2 not being able to host more than one rails app at a time. Do you have any idea if this is true or not?

We also had a whole lot of trouble getting warbler to work correctly. Obviously it's stable enough now for you to use in production. Do you have capistrano create the war file on the production server? If so could you show us the code for how you did that. Also, what is your rationale for warming up the production servers with curl. Is this so you can keep the rails environment in memory?
Yes, we are on v2. Warbler works ok, its a little slow. We do it on the servers via cap -- basically we do a few steps:

1) Stop domain
2) Warble
3) Start domain
4) Deploy
5) Stop domain
6) Start domain
7) Curl everything until the URLs come back instantly

We curl because basically glassfish has a ruby runtime pool (8 right now for us on EC2) and so there is a very large startup time penalty since JRuby has to lex, parse, and interpret all of the gems 8 times over (and stick the AST in RAM :( ). Curl'ing basically warms all these things up.

Possym
Oct 5, 2002
no pants? no problem!
hey so i'm just starting out with ror and i've gone through a couple of tutorials, but i find that i learn the best when i just try to make something i think up. anyway so i'm making a site so people could post show listings. anyway i have a question concerning ajax auto-completion.

this is code from my create show page. it displays all the current bands added and adds a textfield with a button so people can add more bands.
code:
<h2>Bands</h2>
	<ul id="band_list">
			<% session[:bands].each do |b| %>
				<li><%= b.name %></li>
			<% end %>
	</ul>
</p>

<div id="add_band">
	<% form_remote_tag(:url=> {:action=>'add_band'}, 
	:update=>"band_list", :position=>:bottom,
	:html=> {:id=> 'band_form'}) do	%>
		Name: <%= text_field_with_auto_complete :band, :name %>
		
	<%= submit_tag 'Add' %>
	<% end %>
</div>
what i want is to make each textfield have an autocomplete based on whatever is in the band table. i tried using this scriptaculos auto complete, but i get this error:

code:
undefined method `auto_complete_for' for ShowsController:Class
the line they're complaining about is: auto_complete_for :band, :name in my controller. i thought i followed the directions correctly, but obviously it isn't working. does anyone see something wrong?

manero
Jan 30, 2006

Possym posted:

what i want is to make each textfield have an autocomplete based on whatever is in the band table. i tried using this scriptaculos auto complete, but i get this error:

code:
undefined method `auto_complete_for' for ShowsController:Class
the line they're complaining about is: auto_complete_for :band, :name in my controller. i thought i followed the directions correctly, but obviously it isn't working. does anyone see something wrong?

You probably need http://github.com/rails/auto_complete/tree/master since auto_complete stuff has been moved out of core.

mister_gosh
May 24, 2002

I'm considering learning and writing a RoR program(s) basically for the hell of it, to learn it. I have a need for a web application that is database dependent (Oracle 10g). If I do not go with RoR there is no way I'd even consider PHP, I'd use Java, JSP, Javascript, etc.

So, given my background and disapproval of PHP, does this sound like a wise use of my time? I'm curious just so I can put another skill under my belt, but that's probably the wrong reason to get into this.

Also, can RoR scripts be runnable from a command line if I had such a use? Can it communicate with COM objects?

Adbot
ADBOT LOVES YOU

Hop Pocket
Sep 23, 2003

mister_gosh posted:

I'm considering learning and writing a RoR program(s) basically for the hell of it, to learn it. I have a need for a web application that is database dependent (Oracle 10g). If I do not go with RoR there is no way I'd even consider PHP, I'd use Java, JSP, Javascript, etc.

So, given my background and disapproval of PHP, does this sound like a wise use of my time? I'm curious just so I can put another skill under my belt, but that's probably the wrong reason to get into this.

Also, can RoR scripts be runnable from a command line if I had such a use? Can it communicate with COM objects?

I think that's the *right* reason to do it, at least the fact that you have a need for a web application. That's basically how I learned Ruby and Rails. I came from a Java/Spring/Hibernate/J2EE background, and I was astounded at how quickly I could build a good web application using Rails.

There are a number of scripts available to you in the 'scripts' directory in a default rails project root. One of which is called 'runner'. You might use it like this:

code:
% ruby script/runner 'Page.update_all_from_rss'
Regarding COM objects, I've no idea.

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