|
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)?
|
# ¿ Nov 10, 2007 19:52 |
|
|
# ¿ May 3, 2024 17:28 |
|
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.
|
# ¿ Nov 12, 2007 18:04 |
|
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.
|
# ¿ Nov 12, 2007 23:25 |
|
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:
|
# ¿ Nov 18, 2007 16:07 |
|
MrSaturn posted:
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:
code:
|
# ¿ Nov 18, 2007 20:44 |
|
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: 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:
With regards to the comments controller, is your RJS template getting invoked?
|
# ¿ Nov 18, 2007 21:08 |
|
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: 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:
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.
|
# ¿ Nov 18, 2007 21:36 |
|
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 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 Hop Pocket fucked around with this message at 22:34 on Nov 18, 2007 |
# ¿ Nov 18, 2007 22:03 |
|
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.
|
# ¿ Nov 20, 2007 17:49 |
|
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.
|
# ¿ Nov 20, 2007 20:37 |
|
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:
code:
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?
|
# ¿ Nov 21, 2007 18:46 |
|
Thanks guys. Assigning it to the category_id seems to work well.
|
# ¿ Nov 21, 2007 19:32 |
|
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:
code:
vvvv thanks, that worked perfectly Hop Pocket fucked around with this message at 16:10 on Nov 22, 2007 |
# ¿ Nov 21, 2007 21:29 |
|
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 |
# ¿ Nov 22, 2007 17:43 |
|
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?
|
# ¿ Nov 23, 2007 17:57 |
|
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?
|
# ¿ Nov 23, 2007 23:37 |
|
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): I'm not sure what could cause that problem, but here's my RSS implementation: rss_controller.rb code:
code:
|
# ¿ Nov 26, 2007 04:12 |
|
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.
|
# ¿ Nov 28, 2007 23:30 |
|
You can also use content_for to supply extra information to your layout. application.rhtml code:
code:
|
# ¿ Dec 5, 2007 05:00 |
|
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:
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 |
# ¿ Dec 10, 2007 22:33 |
|
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?
|
# ¿ Dec 16, 2007 15:20 |
|
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 Hop Pocket fucked around with this message at 04:07 on Dec 18, 2007 |
# ¿ Dec 17, 2007 17:11 |
|
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 |
# ¿ Dec 20, 2007 21:32 |
|
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.
|
# ¿ Dec 24, 2007 04:43 |
|
dustgun posted:It's just all so expensive for something that I'm not sure will last 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.
|
# ¿ Dec 24, 2007 14:46 |
|
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:
code:
Ideas?
|
# ¿ Dec 24, 2007 21:47 |
|
I seem to have broken something :P I upgraded ruby to 1.8.6 on the Solaris instance our site is deployed on:code:
code:
code:
|
# ¿ Dec 29, 2007 13:18 |
|
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. Good idea. I was able to turn the MySQL log on, and found that the commands are executing on the backend. code:
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?
|
# ¿ Dec 30, 2007 13:43 |
|
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:
Hop Pocket fucked around with this message at 19:40 on Dec 30, 2007 |
# ¿ Dec 30, 2007 19:13 |
|
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.
|
# ¿ Dec 31, 2007 14:29 |
|
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.
|
# ¿ Dec 31, 2007 14:40 |
|
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:
code:
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:
code:
Hop Pocket fucked around with this message at 14:08 on Jan 8, 2008 |
# ¿ Jan 7, 2008 22:45 |
|
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.
|
# ¿ Jan 8, 2008 18:25 |
|
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 |
# ¿ Jan 11, 2008 15:40 |
|
skidooer posted:Write it in the public directory, under the same directory structure that your route implements. 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 |
# ¿ Jan 11, 2008 20:14 |
|
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 |
# ¿ Feb 4, 2008 15:31 |
|
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.
|
# ¿ Feb 14, 2008 13:15 |
|
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. In your controller: code:
|
# ¿ Feb 28, 2008 14:11 |
|
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.
|
# ¿ Feb 28, 2008 14:17 |
|
|
# ¿ May 3, 2024 17:28 |
|
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.
|
# ¿ Feb 29, 2008 00:48 |