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
Hop Pocket
Sep 23, 2003

I've been using my free time to code some RoR apps, and it's going fairly well. I have a dreamhost account that uses FastCGI to run the rails apps. When I deploy using Capistrano, there's a 10-15 second delay which is I'm assuming the FastCGI processes restarting because of the application change. However, if I check the deployed site after an hour or two of inactivity, I get the same delay.

In both cases, the site runs snappy after the first hit to the webapp. Is there a way to force the FastCGI processes to stay running (assuming that this is the cause of the delay)?

Adbot
ADBOT LOVES YOU

Hop Pocket
Sep 23, 2003

What is the rails equivalent of a Quartz scheduler? I want something that will execute periodic jobs on the development/production servers. I'd prefer to stay outside of the OS level cron and inside the application if possible in case our production server ends up being hosted on Windows.

Hop Pocket
Sep 23, 2003

Thanks for the responses. I was really confused about this but think I understand it a bit better now. At any rate, I don't see any reason why I would be forced to host on a windows machine. I'm coming from five years of Java / J2EE development, and am used to being very scared of deploying a solution that is OS dependent.

Hop Pocket
Sep 23, 2003

Sometimes after my laptop sleeps and then wakes up, my local RoR app running at :3000 will "break". That is, I will get a "broken pipe" error for any controller action.

code:
Errno::EPIPE (Broken pipe):
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1042:in `flush'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:1042:in `write'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:462:in `write'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:436:in `command'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/mysql.rb:307:in `stat'
    ......
Is there a way to fix this without simply restarting Mongrel?

Hop Pocket
Sep 23, 2003

MrSaturn posted:

code:
<%= link_to 'comments', :action => :showcomments, :id => this.id %>
which points to a .rjs file called showcomments.rjs in that view folder.
The rjs file looks like this:
code:
page[:comments_11].visual_effect :toggle_blind
first off, I can't quite figure out what I need to do to make that "11" in the .rjs dynamic. Secondly, when I click on the link that's made in the blog, I just get forwarded to
/front/showcomments/11


Funny, I was just working on the very same thing today. Really. I believe that you need to use a link_to_remote to force a JS request. That way your RJS template will be evaluated by the browser JS engine on return. The fact that you're using link_to means that it's generating an A tag that will force a page reload, which is not what you're wanting, I think.

Secondly, in your RJS template, use an instance member that your controller makes available to control the id.

code:
def show_comments
  @file = File.find(params[:id])
  ....
end
Then, in your RJS:

code:
div_id = "comments_#{@file.id}"
page.replace_html div_id, :partial=>'your_partial_goes_here_to_render_the_comments'
page[div_id].visual_effect :toggle_blind
I've assumed that you're wanting to do some content insertion, which is why I used the replace_html. Sorry if that's not the case.

Hop Pocket
Sep 23, 2003

MrSaturn posted:

I'm getting closer... if I keep the comments_11 in the .rjs, I get these 2 errors when I click my link:

code:
RJS error:

TypeError: Effect[klass] is not a constructor

and then 

$("comments_11").visualEffect("toggle_blind");
if I modify the comments controller like you showed, nothing happens at all.

It sounds like you may not have the javascript libraries loaded. In your <HEAD> tag in your layout or template, make sure you have:

code:
<%= javascript_include_tag :defaults %> 
That will load the scriptaculous (and other) libraries on which the RJS-generated code is dependent.

With regards to the comments controller, is your RJS template getting invoked?

Hop Pocket
Sep 23, 2003

MrSaturn posted:

I've definitely got javascript loaded up. And i'm pretty sure the rjs template is invoked directly from the link_to_remote that I put in:

code:
<%= link_to_remote 'comments', :url => '/front/showcomments/' + this.id.to_s %>
should I be putting the controller logic in the comments controller, or the frontpage controller?

To be honest, I'm not sure. It probably doesn't matter a whole lot, as long as you're sure that the controller is getting invoked. You can verify this by looking at the rails console, which will output each controller action that is executed.

I would probably recommend as well that you structure your links like this:

code:
<%= link_to_remote 'comments', :url=>{ :controller=>:comments, :action=>:showcomments, :id=>@file } %>
Assuming that you have a controller called "comments", and an action within that controller called "showcomments" and that you have an instance member available called @file.

Anal Wink posted:

Edit: Only hit the server when you have to go and get (a lot of) new data, or update things, as it's relatively expensive to do. For something like blog comments, all of them should be sent with the blog post, or at least the first page of 40 or so.

Yes, this is good advice. If you've already got the data that you need on the page and you wish to work solely within that realm, no need to hit the server. I was under the assumption that you were loading the comments from the db in your 'showcomments' action.

Hop Pocket
Sep 23, 2003

MrSaturn posted:

yeah, I wasn't. I'm trying to do it inline now. I'm going to use Element.toggle for now, until I can figure everything else out. Then I'll get fancy with scriptaculous :smith:

If you've got the $25 bucks to spend, I'd really recommend the 'Agile Development With Rails' PDF available here. It helped me out with a lot of rails stuff. May help you, depending on where you are.

vvv :cool:

Hop Pocket fucked around with this message at 22:34 on Nov 18, 2007

Hop Pocket
Sep 23, 2003

Having had to unfortunately work with FastCGI instead of Mongrel recently, I can understand your pain. But yeah, try to look into using Mongrel instead.

Hop Pocket
Sep 23, 2003

For those of you using Mongrel in a deployment environment, how many Mongrel processes do you start? I know that it's all dependent on the application, load, # of static pages, etc. I'm setting up some hosting with Joyent, and you have to request Mongrel ports for a shared hosting environment, so I was just curious.

Hop Pocket
Sep 23, 2003

I have a question about using forms. For this project I am doing, I have Events and Categories. An Event belongs_to a Category, so I have the event.category relationship.

In my Event form, I want to represent this as a select list. However, I am not really sure of the best way to go about it.

I'm currently trying:

code:
<%= f.select(:category, @categories.map {|c| [c.name,c.id]}) %>
And this renders the select list correctly when the form loads. However, upon submitting I get the error:

code:
Category expected, got String
Which is understandable, as it's trying to assign a String ID to the Category property of the Event model.

In Spring WebMVC, we used PropertyEditors to handle the conversion to and from ids and model objects. Is there anything like that in Rails? What's the 'normal' way to go about linking up a separate model object in a form?

Hop Pocket
Sep 23, 2003

Thanks guys. Assigning it to the category_id seems to work well.

Hop Pocket
Sep 23, 2003

You've all been really helpful. I have one more question. I'm writing my own form builder, and I want all of my form fields to go inside of a <table>. What I'd like to do is to:

code:
<% form_for :event, :builder=>EventFormBuilder, ..... do |f|  %>

  <% f.inside_table do %>
       
       <%= f.text_field... %>

  <% end>

<% end %>
I'm having trouble getting the inside_table method to do what I want. I essentially want it to be something like this:

code:

def inside_table
  puts "<table ...>"
  yield
  puts "</table>"
end

But of course puts outputs to the console. I can't figure out how to get inside_table to insert markup into the page. It's easy when you use <%= %> because you can just return the string, but helper methods using <% %> don't seem to work the same way.

vvvv thanks, that worked perfectly :cool:

Hop Pocket fucked around with this message at 16:10 on Nov 22, 2007

Hop Pocket
Sep 23, 2003

Grob posted:

One thing to consider is if you use Haml for markup (which I do and love), they have their own puts methods you can use in helpers, so your above code would work!

I'm looking at the Haml documentation right now.. Looks awesome. Though, my production host (DreamHost) does not have the Haml gem installed. I Haml'd my rails app and it looks like it installs a plugin that simply requires the gem.

Is there a way that I could install Haml on my project in a way that didn't require the gem to be installed on the production host?

Also, thanks!

edit: I think I figured it out:

guiness:events$ ruby script/plugin install http://svn.hamptoncatlin.com/haml/tags/stable --force

Hop Pocket fucked around with this message at 17:53 on Nov 22, 2007

Hop Pocket
Sep 23, 2003

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?

Hop Pocket
Sep 23, 2003

ikari posted:

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.

Yeah, I can see where you're coming from. In my situation though the production server is really just the staging server -- i.e. that's where i show my work to my clients that are usually remote. So it would not have any far-reaching consequences for the most part. Does Capistrano not have this ability?

Hop Pocket
Sep 23, 2003

MrSaturn posted:

I've got another question: I'm trying to add an rss feed to my blog, but I'm missing something. In my blogposts controller, I added the following code (from http://paulsturgess.co.uk/articles/show/13-creating-an-rss-feed-in-ruby-on-rails):

code:
  def rss
    @blogposts = Blogpost.find(:all, :order=> "id DESC")
    render_without_layout
    @headers["Content=Type"] = "application/xml; charset utf-8"
  end
However, when I go to http://puddl.es:3002/blogposts/rss, I get "Can't find Blogpost: rss"

What'm I doing wrong? I've restarted my servers, I've tried putting the def rss in the frontpage's controller and moving the accompanying rss.rxml file to that view folder, and nothing seems to fix this.

I'm not sure what could cause that problem, but here's my RSS implementation:

rss_controller.rb
code:
class RssController < ApplicationController
  def news
    @newsitems = Newsitem.find(:all, :order=>'created desc')
    render :layout=>false
  end
end
views/rss/news.rxml:
code:
xml.instruct! :xml, :version=>"1.0" 
xml.rss(:version=>"2.0"){
  xml.channel{
    xml.title("PeeOutside.org News")
    xml.link("http://peeoutside.org/rss/news")
    xml.description("Recent news from PeeOutside.org")
    xml.language('en-us')
      for newsitem in @newsitems
        xml.item do
          xml.title(newsitem.title)
          xml.category('General News')           
          xml.description(newsitem.body)           
          xml.pubDate(newsitem.created.strftime("%a, %d %b %Y %H:%M:%S %z"))
          xml.link('http://peeoutside.org/pee/newsitem/'  + newsitem.id.to_s)
          xml.guid('http://peeoutside.org/pee/newsitem/' + newsitem.id.to_s)
        end
      end
  }
}

Hop Pocket
Sep 23, 2003

Is there a way to disable SQL logging for some statements within Rails? I have an images table that I'm uploading somewhat large files to, and the SQL logging is causing all sorts of Terminal.app problems. I don't want to disable SQL logging completely in the development environment, but I would like to be able to not have it log those statement that are doing INSERTs into the images table.

Hop Pocket
Sep 23, 2003

You can also use content_for to supply extra information to your layout.

application.rhtml

code:
....
<head>
  <title><%= yield :title %></title>
</head>
....
view.rhtml

code:
<% content_for(:title) do %>
I am a title, short and stout
<% end %>

Hop Pocket
Sep 23, 2003

I need to do a left join on a table in an AR query to select either joined rows that are NULL (where the association did not exist) or where there is a certain value (in the case that the association did exist).

code:
events = Event.paginate(
:per_page=>4,
:page=>page,
:joins=>"LEFT JOIN votes ON (events.id = votes.event_id and 
      votes.user_id = #{user.id})",
:order=>'events.created DESC',
:conditions=>['((votes.dig = 1 OR votes.dig IS NULL) AND votes.user_id = ?) 
      OR votes.id IS NULL', user.id]
)
The problem here is that the fields from the Vote join are polluting the Event. In this particular case, let's say that there are no Votes at all. The result set coming back from mysql has NULL for each Vote id, as it should. However, AR is populating that id field from the Vote into the Event model.

This means that each Event coming out of this query either has a null id or the id of its associated Vote. I suspect that it's a problem with the result set coming back from MySQL. The column names for the Event id and the Vote id are the exact same name: id.

Any ideas?

note: I am using will_paginate, and I tried this query using the straight up AR find(:all, ....) with the same results.

EDIT 2: Hooray! :select => "events.*" seemed to do the trick.

Hop Pocket fucked around with this message at 22:58 on Dec 10, 2007

Hop Pocket
Sep 23, 2003

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?

Hop Pocket
Sep 23, 2003

Thanks for the help with the RJS. I used the delay / duration combo successfully. Will look more into the method chaining, but that's just a bit over my head at the moment.


vvvv word, thanks. That will come in very handy :cool:

Hop Pocket fucked around with this message at 04:07 on Dec 18, 2007

Hop Pocket
Sep 23, 2003

I am just starting to get into Rails caching, and so far so good. I have some expensive things in my layouts that I want to cache using fragment caching, but would probably want to expire just those fragments as the contents of the layout code changes. Ideally I'd be able to simply wipe out these fragment caches every time I deploy my app.

Is this best done using a Capistrano task?

EDIT: Nevermind. I realize now that if I store my cached files in the project directory under tmp/cache, that will automatically get reset by the svn export when Capistrano deploys the app. Awesome.

Hop Pocket fucked around with this message at 21:56 on Dec 20, 2007

Hop Pocket
Sep 23, 2003

dustgun posted:

What hosts are you internet dudes using for your rails stuff?

I'm using Joyent. I don't have a good frame of reference, as I'm fairly new to Rails and that particular world, but I will say that I have found their support to be really helpful and responsive.

Hop Pocket
Sep 23, 2003

dustgun posted:

It's just all so expensive for something that I'm not sure will last :(

How flexible are they with upgrading bandwidth once you're a customer? I'm pushing around 10GB a day right now, going up around 1.5GB a week (nearly all of which are images I could probably keep on dreamhost, or toss on S3 or something I guess). I also do image processing in 1080p a dozen or so times a day, so, I'm sort of wondering how their CPU bursting stuff works. Do you get charged for it? Is this is just something I should email about?

Railsmachine looks to be way out of my price range right now, at any rate.

Someone above alluded to this before, but there are two different types of Joyent accounts.. The shared hosting (which I think is called their Shared Connector / Accelerator, formerly known as Textdrive), and then the virtual dedicated hosting, aka Accelerator.

The latter gives you the ability to upgrade to more guaranteed memory / cpu / burst when necessary. No such guarantees are really given for the shared hosting.

To be honest, I have sites running on both the virtual dedicated and the shared environments. The shared environment is a bit flakey. It tends to go down more frequently than I would like. However, I don't have any such problems with the virtual dedicated server.

Hop Pocket
Sep 23, 2003

Does anyone know how to get the current session id? I have a filter that I'm using to audit the controller name, action name, and request parameters. I'd like to add a session id as well.

code:
audit.session_id = session.id
That seems to produce a number of sorts that increments every request. I'm looking for the long hex string like

code:
f56e3ee404151f8c0a90928723c86e5c
FWIW, I am using the ActiveRecord session store.

Ideas?

Hop Pocket
Sep 23, 2003

I seem to have broken something :P I upgraded ruby to 1.8.6 on the Solaris instance our site is deployed on:

code:
./configure --prefix=/opt/csw
make
sudo make install
Running ruby -v gives me 1.8.6, as expected. Things still work, except for migrations. On the production server:

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?

Hop Pocket
Sep 23, 2003

Heffer posted:

Can you try catching that command as its executed on the mysql server? I forget what the best way is to find the currently executing command from the mysql admin tools.

Then you can make sure that variable value is getting parsed out, and then execute it yourself on the database to make sure it works.

Good idea. I was able to turn the MySQL log on, and found that the commands are executing on the backend.

code:
...
3 Query       SHOW KEYS FROM events
3 Query       SHOW FIELDS FROM events_tags
3 Query       SHOW KEYS FROM events_tags
3 Query       SHOW FIELDS FROM images
3 Query       SHOW KEYS FROM images
3 Query       SHOW FIELDS FROM questions
3 Query       SHOW KEYS FROM questions
3 Query       SHOW FIELDS FROM repeat_intervals
3 Query       SHOW KEYS FROM repeat_intervals
Trying this last command in a MySQL prompt seems to work perfectly.

quote:

Reinstaling the MySQL gem could be worth a shot.

I've had problems building just about anything on this Solaris box, so I'm a little nervous.Is there a way to test a gem build without doing a gem remove and then a gem install?

Hop Pocket
Sep 23, 2003

ikari posted:

Reinstaling the MySQL gem could be worth a shot.

Removing the MySQL gem seemed to fix it. I'll see what I can do about re-installing the MySQL gem.

EDIT. Trying to re-install the MySQL gem did not work well at all..

code:
admin: /opt/csw/lib/ruby/gems/1.8/gems $ sudo gem install mysql -- --with-mysql-dir=/opt/csw/mysql5
Select which gem to install for your platform (i386-solaris2.11)
 1. mysql 2.7.3 (mswin32)
 2. mysql 2.7.1 (mswin32)
 3. mysql 2.7 (ruby)
 4. mysql 2.6 (ruby)
 5. Skip this gem
 6. Cancel installation
> 3
ERROR:  While executing gem ... (ArgumentError)
    install directory "/opt/csw//lib/ruby/gems/1.8/gems/mysql-2.7" not absolute
I made sure the directory did not exist before I tried to install the MySQL gem. Have you guys seen that before?

Hop Pocket fucked around with this message at 19:40 on Dec 30, 2007

Hop Pocket
Sep 23, 2003

Unixmonkey posted:

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

Yeah, but I guess I'm not sure why the // is happening. I figured it was a problem with how I had configured ruby before I built and installed it. I thought that originally I had perhaps specified --prefix=/opt/csw/ and that the trailing slash was responsible fore the // when trying to build the mysql gem. I re-installed ruby then with --prefix=/opt/csw (without the trailing slash) and had the same problem.

Hop Pocket
Sep 23, 2003

Well, I was able to re-install the mysql gem! Using the --exec-prefix option, and specifying the same value as --prefix, seemed to do the trick. However, I'm still segfaulting when trying to run a migration. If I uninstall the mysql gem, the migrations work fine. Thanks for the help so far.

Hop Pocket
Sep 23, 2003

This is a ferret question. I have the ferret_server DRb server up and running, but I'm trying to get it so that I can restart the ferret server through Capistrano whenever I restart the Mongrel processes. Not having a lot of luck with this at the bottom of my deploy.rb:

code:
task :post_deployment do
  run "cd /home/site.com/web/rails/current/ && script/ferret_server -e production stop"
  run "cd /home/site.com/web/rails/current/ && script/ferret_server -e production start"
end

after 'deploy:restart', :post_deployment
After the restart it tries to execute the stop and then start, but fails:

code:
 ** [out :: [email]site.com@site.com[/email]] no such file to load -- /usr/bin/../config/environment
    command finished
So it looks like it's not respecting the current directory. Any ideas on how to get around this? I have to restart the DRb ferret_server each time so that it picks up the new index location.

edit: Crossposted this to the ruby forums because I'm kind of under some pressure to get this thing finished. Sorry if you guys see this post in multiple places

vvv solution

--------------

In order to get this to work, I created a script/restart_ferret.sh script:

code:
#!/bin/sh

cd /home/site.com/web/rails/current
script/ferret_server -e production stop
script/ferret_server -e production start
And in the deploy.rb:

code:
task :post_deployment do
  run "bash -c /home/site.com/web/rails/current/script/restart_ferret.sh"
end
That seems to work.

Hop Pocket fucked around with this message at 14:08 on Jan 8, 2008

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.

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

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

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

Hop Pocket
Sep 23, 2003

There was a guy at the Atlanta ruby user's group last night that demo'd his site that is similar to this (http://mor.ph/), albeit not exactly the same.

Hop Pocket
Sep 23, 2003

freeb0rn posted:

Does anyone know if I can figure out within an action (in a controller) if the action has been called "remotely" (all AJAX-like) or not? Apart from sending some sort of special parameter when you update remotely and figuring it out on your own, that is.

EDIT:
Apparently this is done by inspecting the Accept header and using respond_to, which is what I thought but hadn't figured out how, exactly.
This little excerpt I found sheds some more light on the situation:

In your controller:

code:
def create_something
  if request.xhr?
    # the request was made using some sort of ajax black magic.
  end
end

Hop Pocket
Sep 23, 2003

Sewer Adventure posted:

Any way to get rails to handle concurrent connections?

Rails is single-threaded, so I don't believe you'll be able to do that. In production, a common solution is to simply have a pack of mongrel processes that traffic gets proxied to by an Apache load balancer.

Adbot
ADBOT LOVES YOU

Hop Pocket
Sep 23, 2003

freeb0rn posted:

Yeah I'm using that second approach.

I will be too in the future. A much better way of doing it, I now see. Thanks guys.

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