|
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 |
|
|
# ? Apr 24, 2024 08:22 |
|
Hop Pocket posted: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. I looked for something like this months ago and couldn't come up with anything. So my site uses cron for all jobs, using the "script/runner"
|
# ? Nov 12, 2007 18:49 |
|
You won't find a Quartz-alike until rails runs in a threaded app server. Rails apps are triggered by events like a user hitting a page. There's no constant thread running that can be used to do stuff like run jobs.
|
# ? Nov 12, 2007 19:10 |
|
Hop Pocket posted:What is the rails equivalent of a Quartz scheduler? I want something that will execute periodic jobs on the development/production servers.
|
# ? Nov 12, 2007 19:39 |
|
skidooer posted:Backgroundrb should fit the bill. Looks like they're dropping support for Windows, though.
|
# ? Nov 12, 2007 20:23 |
|
I would understand that sometimes you might have to, but if you don't need to would you really try to host a Rails application on a Windows server?
|
# ? Nov 12, 2007 22:32 |
|
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 |
|
maybe some of you rails gurus can help me with this. I'm running instant rails on a windows host machine, and I recently bought a domain name that i want to use to point to one of my rails apps. It's running on port 3002 locally (http://localhost:3002) and I just can't figure out how to reroute that to go to the default port (80 I suppose) that my domain will be referencing. I have the domain registered through mydomain, and I can get to the application if I go to the domain with a port extension on it (http://domain.com:3002) but http://domain.com doesn't work. I have a feeling that my ISP may block port 80 incoming, but I'm not sure. I subscribe to comcast cable, if that helps. What config do I have to edit to make this all work?
|
# ? Nov 14, 2007 07:05 |
|
Manage Rails Applications -> Configure startup mode
|
# ? Nov 14, 2007 07:24 |
|
Try port routing in your router settings, set up port 80 to point to port 3002 on your local computer. This will only work if your ISP doesn't block incoming connections to port 80.
|
# ? Nov 14, 2007 09:03 |
|
Is either one of acts_as_searchable or acts_as_ferret inherently better than the other?
|
# ? Nov 17, 2007 07:00 |
|
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 |
|
So I've made this odd little blog type page for myself, just to experiment with some techniques I haven't yet used. I'm trying to use the scriptaculous stuff built into rails to show/hide the comments on a given post. Right now, all the comments for a post are in a code:
code:
The rjs file looks like this: code:
/front/showcomments/11 and it says code:
if you want to see the page, it's temporarily located at http://jivewise.livenode.com:3002/ (until I can get the port forwarding problems I talked about above sorted out)
|
# ? Nov 18, 2007 20:29 |
|
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 |
|
Hop Pocket 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. I'm getting closer... if I keep the comments_11 in the .rjs, I get these 2 errors when I click my link: code:
|
# ? Nov 18, 2007 20:57 |
|
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 |
|
Hop Pocket posted:It sounds like you may not have the javascript libraries loaded. In your <HEAD> tag in your layout or template, make sure you have: 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:
|
# ? Nov 18, 2007 21:16 |
|
Also keep in mind that even when you get this working, it's really not the best way of going about it. Every time they click the show/hide button, they are being sent to the server to get the 1 line of javascript to do the show or hide. This should be done as an inline js function, allong the lines of:code:
Pardot fucked around with this message at 21:25 on Nov 18, 2007 |
# ? Nov 18, 2007 21:22 |
|
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 |
|
Hop Pocket 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
|
# ? Nov 18, 2007 21:57 |
|
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 |
|
Hop Pocket posted: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. it's sitting right next to me on my desk. I use it all the time, the only thing is I'm using the hobo plugin for my apps, which tends to add an element of complexity to my understanding the book. Great book, though, hands down.
|
# ? Nov 18, 2007 22:21 |
|
Ooooo got it working. Snazzy, eh? http://jivewise.livenode.com:3002/ ...now to let people add comments via ajax so they don't ever leave the frontpage...
|
# ? Nov 18, 2007 22:36 |
|
Embarrassingly retarded question... I can't believe I can't figure out the answer to this on my own. Imagine I've got something like the following:code:
code:
|
# ? Nov 19, 2007 14:51 |
|
SeventySeven posted:Embarrassingly retarded question... I can't believe I can't figure out the answer to this on my own. Imagine I've got something like the following: code:
|
# ? Nov 19, 2007 15:29 |
|
Why didn't I think of that? I tried @posts.length and @posts.count. Thanks.
|
# ? Nov 19, 2007 15:46 |
|
SeventySeven posted:Why didn't I think of that? I tried @posts.length and @posts.count. Actually @posts.length should work too. @posts.size is equivalent, so I'm not sure why that failed!
|
# ? Nov 19, 2007 15:47 |
|
Grob posted:Actually @posts.length should work too. @posts.size is equivalent, so I'm not sure why that failed! Hmm, so it does, guess I forgot what I tried. It all seems so obvious now.
|
# ? Nov 19, 2007 16:03 |
|
I've always used if @posts.nil? || if @posts.blank?
|
# ? Nov 19, 2007 16:24 |
|
@posts.empty?
|
# ? Nov 19, 2007 18:12 |
|
atastypie posted:I've always used
|
# ? Nov 19, 2007 19:30 |
|
burntoutjoy posted:@posts.empty? This is the best one right here. Short, concrete, and simple.
|
# ? Nov 19, 2007 21:43 |
|
skidooer posted:Your nil? check is redundant considering that blank? will return false if @posts is nil. Is "blank?" what I am looking for? I've always wanted something similar to @posts.title.empty_or_nil? In case the value being returned in the database is blank instead of nil for whatever reason, as nil.empty? would return an error. Or.. does it? I'm getting confused. I seem to just remember creating my own empty_or_nil? method at some point before to handle it. Nolgthorn fucked around with this message at 06:50 on Nov 20, 2007 |
# ? Nov 20, 2007 06:46 |
|
Nolgthorn posted:Is "blank?" what I am looking for?
|
# ? Nov 20, 2007 08:39 |
|
I'm a PHP coder who is nearing completion on my first RoR project. The project is to port someone's large spaghetti bowl of a MsAccess app to MySQL/RoR. I (alas!) can't change the database layout, including table and column names, due to design constraints beyond my control. Here's what I liked and disliked about the RoR experience. The Good: - Database migrations. These are truly lovely. At any time I can drop the entire db structure, then recreate it and copy the live data over from SQL Server. Or just downgrade the data migration and then run it again. This allows me to test against a copy of the live data and then reset my copy once I feel I've corrupted the data too much. - Enforced (or at least strongly encouraged) MVC design pattern. Sure, it's nice.. that said I was using MVC previously in both CakePHP and later my own simple custom framework. - Helpers are cool. I'd rather type <%= text_field :object, :accessor, :etc %> than <input type="text" ... />, and they become especially cool when I need to read the input data in a controller. form_for is bitchen. The Bad: - Documentation. For gently caress's sake people, at least pretend like you're trying. I'd say around 90% of the helpers and controller methods I found on api.rubyonrails.org had "options = {}" in the signature without any further information. In the entire page. For as many people here hate PHP, some of you must have tried it. Remember the documentation? It has a search box, for one. It also tells you exactly which PHP versions the function in question works in, and any differences between those versions. The PHP docs are also available in something like 22 different languages. - Server restarts. Our dev server is also, unfortunately, a production server for different apps in other languages. (don't blame me, I didn't do it ). Under Apache/FastCGI/RoR there are too many times we need to restart Apache. Changed something in environment.rb? Restart Apache. Added/Edited something in the /lib path? Restart Apache. This makes any sort of iterative development of libs/mixins a huge pain in the rear end. Particularly since I have to go beg the sysadmin to restart Apache.. How is this even considered acceptable? Is it just assumed that one server will run only one RoR app? There are live apps being taken offline every time I need to update a library. - SQL Logging. Didn't work, even when I triple checked that the /tmp and /log dirs had proper permissions and that logging wasn't disabled in the environment files. I even tried chmodding /tmp and /log to 777, still no logs. There were a couple situations where knowing what sort of SQL ActiveRecord was generating would've saved us some serious headaches. The Gotchas: - 'type' db field. The original MSSQL db had a 'type' field in one of the tables. It can be used as a regular field, but only after putting a dummy value in the model for inheritance_column, then accessing the member as object[:type] instead of object.type. This of course breaks all attributes= and object.attributes calls, requiring an extra line after them that explicitly sets object[:type]. - You still write SQL, for any sort of advanced find / sort. Not that I mind writing SQL, but I prefer to write it in one large understandable chunk instead of splitting it up into mini-clauses, like :conditions => "[some sql]", :order => "[some sql]", etc. Most find queries that required a JOIN or two had to be written using find_by_sql. Again, I like sql, but I feel like I'm cheating every time I use it in Rails. - Controller initialize function. It causes "Internal Server Error" when I put simple logic in there. Example (this kills rails): "if null != params[:a_param]; end". Same thing when I put the logic in question into a method and call it from initialize. No problems when I call that same method from one of the actions instead. - Different expectations for overriding ActionController::initialize and ActiveRecord::initialize. Many working code examples override initialize in a controller without calling super(). To be sure this was safe, I even looked at the code for ActionController::initialize which is an empty function. Later, assuming that this was a Rails convention (remember "convention over configuration"?), I overrode a model's initialize method without calling super. Hilarity ensued as I tried to track down why an object created in one line had none of its members in the next, even though it wasn't nil. In conclusion Rails didn't work for me this time around. Once I've finished this project I'll gladly put Rails down for a time and maybe try again once it's matured some. Perhaps it's just that the project required too much custom tweaking, I'm not sure. I came up against ActiveRecord's limitations several times, along with some of the more esoteric Rails gotchas. I've only listed a few here, but I'd estimate that 15 - 20 minutes of every hour were spent looking for help when Rails' "magic" turned evil, or looking for documentation on helpers. In most cases I'd find the answer on somebody's blog, usually 3 pages into a google result set, after trying in vain to find the relevant info in RoR's documentation. While the above issues were all annoyances, the need to restart Apache after making code, not configuration, changes is the kicker. In contrast, we have a PHP application that's been running for three years solid without any downtime except for electrical problems/server room maintenance. We make changes to the codebase fairly regularly without ever requiring an Apache restart. For my work I'm going to continue using PHP, most likely with the Zend Framework. I'm also going to check out Zope/Plone which is supposed to combine a built-in CMS with some new novel way of doing ORM. I feel Rails still has a way to go before it can offer more to your average developer than "Create a blog in x minutes".
|
# ? Nov 20, 2007 10:36 |
|
Nolgthorn posted:Is "blank?" what I am looking for? In the original case empty? would be fine as find(:all) never returns nil.
|
# ? Nov 20, 2007 12:50 |
|
zigb posted:The Bad: Maybe I'm missing something, but why are you running FastCGI for your development server? If nothing else, it's why you were having to reload after changing code in your lib directory. I mean, the whole point of FastCGI is that it doesn't have to reload libraries for every request.
|
# ? Nov 20, 2007 14:57 |
|
zigb posted:Apache/FastCGI/RoR Is there a reason you're not using mongrel?
|
# ? Nov 20, 2007 14:59 |
|
zigb posted:- You still write SQL, for any sort of advanced find / sort. Not that I mind writing SQL, but I prefer to write it in one large understandable chunk instead of splitting it up into mini-clauses, like :conditions => "[some sql]", :order => "[some sql]", etc. Most find queries that required a JOIN or two had to be written using find_by_sql. Again, I like sql, but I feel like I'm cheating every time I use it in Rails. This puzzles me. I just deployed an online RPG game using rails with over 120 models, and I'd say I had to write manual SQL less than 1% of the time. Especially the part where you say a join or two -- what kind of joins are you doing that aren't handled elegantly by ActiveRecord?
|
# ? Nov 20, 2007 15:12 |
|
|
# ? Apr 24, 2024 08:22 |
|
zigb posted:- Server restarts. Our dev server is also, unfortunately, a production server for different apps in other languages. (don't blame me, I didn't do it ). Under Apache/FastCGI/RoR there are too many times we need to restart Apache. Changed something in environment.rb? Restart Apache. Added/Edited something in the /lib path? Restart Apache. This makes any sort of iterative development of libs/mixins a huge pain in the rear end. Particularly since I have to go beg the sysadmin to restart Apache.. How is this even considered acceptable? Is it just assumed that one server will run only one RoR app? There are live apps being taken offline every time I need to update a library. It's been a long time since I used Rails, but doesn't it come with a simple standalone web server you can use for testing? ISTR typing "rails test <appname>" or something starting my app listening on port 8080.
|
# ? Nov 20, 2007 17:07 |