|
kitten smoothie posted:I think the question is what's the value of your time early on in a project. Do you want to spend time computer janitoring a server, or do you want to spend that time writing code that could make you money and deal with migration if it takes off? I have to agree with this as well. Heroku is a really nice way to get your app in to a production environment quickly and allow you to assess the situation from there. If your traffic becomes too much, and you don't want to just pay to scale with Heroku, then just migrate it elsewhere. MrDoDo fucked around with this message at 09:30 on Nov 16, 2012 |
# ? Nov 16, 2012 09:24 |
|
|
# ? May 31, 2024 23:37 |
|
Is there a recommended tutorial that shows mixing Angular with Rails?
|
# ? Nov 17, 2012 18:10 |
|
Bob Morales posted:Is there a recommended tutorial that shows mixing Angular with Rails? I just did some learning about AngularJS last week and it seems to me that if you're going to embrace Angular, you don't need full stack Rails. Angular is going to cover your views and controllers. Just go with Sinatra or something for JSON services that give you objects.
|
# ? Nov 17, 2012 18:29 |
|
Obsurveyor posted:I just did some learning about AngularJS last week and it seems to me that if you're going to embrace Angular, you don't need full stack Rails. Angular is going to cover your views and controllers. Just go with Sinatra or something for JSON services that give you objects. As a long time server-side MVC fan (and fairly recent Rails convert), the idea of client-side controllers makes zero sense to me whatsoever. Would you mind explaining the rationale behind it?
|
# ? Nov 18, 2012 01:15 |
|
They aren't mutually exclusive. Both the client and the server can have an MVC architecture.
|
# ? Nov 18, 2012 01:19 |
|
Lexicon posted:As a long time server-side MVC fan (and fairly recent Rails convert), the idea of client-side controllers makes zero sense to me whatsoever. Would you mind explaining the rationale behind it? "Presenter" would probably be more accurate than controller, though that's what AngularJS calls them. Like Smol said, you can have both server-side and client-side stuff and it really just depends on what exactly you're doing. However, if it's heavy AJAX and lots of dynamic page updates or a single page app, server side controllers kind of go away for the most part, as far as I can see. Lots of stuff from Rails just goes away for single page apps and all you really need is something to save and retrieve objects. You don't need a full Rails stack for that. That Lost Architecture presentation by Bob Martin(he's not my uncle) kind of addresses but doesn't drive home hard enough: Too much of ruby web development focuses on Rails being the star of the show when it should be what the application is doing. I know it has been really, really hard for me to not think of web development as being centered around what the Rails app is doing with all the Rails trimmings and machinery and stuff and the rest of the application and what it does just mixed in. Obsurveyor fucked around with this message at 02:26 on Nov 18, 2012 |
# ? Nov 18, 2012 02:18 |
|
Obsurveyor posted:I just did some learning about AngularJS last week and it seems to me that if you're going to embrace Angular, you don't need full stack Rails. Angular is going to cover your views and controllers. Just go with Sinatra or something for JSON services that give you objects. I think that's what we should end up doing - since we built an API for our mobile apps to use. But we basically re-did parts of the front-end in Node while re-using our existing web app. So we've got two different beasts but the same thing. And when I saw 'we' I mean one programmer who doesn't document anything and plans everything like poo poo.
|
# ? Nov 18, 2012 16:01 |
|
Obsurveyor posted:"Presenter" would probably be more accurate than controller, though that's what AngularJS calls them. Like Smol said, you can have both server-side and client-side stuff and it really just depends on what exactly you're doing. However, if it's heavy AJAX and lots of dynamic page updates or a single page app, server side controllers kind of go away for the most part, as far as I can see. Lots of stuff from Rails just goes away for single page apps and all you really need is something to save and retrieve objects. You don't need a full Rails stack for that. Cool, makes sense. I'll check out that presentation. Thanks.
|
# ? Nov 18, 2012 16:14 |
|
I've always meant to ask this, but never got around to it... what exactly is going on within the respond_to block in this code:code:
|
# ? Nov 18, 2012 16:17 |
|
Lexicon posted:Obviously I know what the outcome of this is, but the calling syntax is bizarre. format.xml or format.json appear to be method calls, but with a conditional baked in? As in, they only execute if the format is indeed xml. Yeah, I don't like a lot of the magic that is built-in to this stuff. I think it gets even more crazy than this. Those methods are passing blocks, I think. It could be re-written: code:
|
# ? Nov 18, 2012 17:03 |
|
As part of my research group, I've been working on a Rails app for a beginner's programming environment. In a nutshell, there's a code writing view where they do their exercises, and on the server we store their code in Git repositories for analysis purposes and so that they can revert easily to previous versions. Since they'll be writing code in-browser, we want to do aggressive auto-saving (as in, a couple seconds after the editor has changed and gone idle). This has the potential to produce a lot of requests between the client and server, and if we have, say, 60 students in the class, a lot of work for the server especially right before due dates. So I've been taking a lot to heart from some posts in this thread about breaking up an app like that into services instead of doing a monolithic Rails app, because I don't want to see it grind to a halt. Here's what I've been thinking:
What would you all suggest, and are there any other things that I should watch out for? I have a decent amount of Rails experience but this is the first time I've designed a system that needs to support a fair number of users where they're like to all hammer it at once, and I want it to scale significantly beyond that in the future. So, I want to make sure I'm not backing myself into a wall here. Is there any configuration I should be changing in Nginx to make sure the server itself can handle it? Flobbster fucked around with this message at 19:18 on Nov 18, 2012 |
# ? Nov 18, 2012 19:15 |
|
Flobbster posted:As part of my research group, I've been working on a Rails app for a beginner's programming environment. In a nutshell, there's a code writing view where they do their exercises, and on the server we store their code in Git repositories for analysis purposes and so that they can revert easily to previous versions. Taking a services oriented approach always involves a bunch of complexity so I would avoid that as long as possible, it doesn't really sound needed here yet. Nginx should be pretty good out of the box, if anything is going to start blocking requests it will be unicorn (or whatever you are using) so run as many of those as needed. I use the 'raindrops' gem to grab metrics on unicorns working vs. queued. I would just throw the code saving into a job queue as well. Since you are going to be running frequent jobs it will probably be better to use something like sidekiq instead of resque/delayed_job. If you want to do something like live updating, https://github.com/maccman/juggernaut (or google server-sent events) would make it soooper simple to push updates over websockets from your ruby/rails background saving jobs. It's a node.js daemon that works via Redis's pub/sub system. Anveo fucked around with this message at 20:36 on Nov 18, 2012 |
# ? Nov 18, 2012 20:24 |
|
Obsurveyor posted:Yeah, I don't like a lot of the magic that is built-in to this stuff. I think it gets even more crazy than this. Those methods are passing blocks, I think. It could be re-written:
|
# ? Nov 18, 2012 20:35 |
|
Obsurveyor posted:Yeah, I don't like a lot of the magic that is built-in to this stuff. I think it gets even more crazy than this. Those methods are passing blocks, I think. It could be re-written: That makes a bit more sense, but I guess there's still an implicit conditional? As in the json() method of format only yields if request.path terminates in .json or something?
|
# ? Nov 18, 2012 20:50 |
|
As the documentation says, it will look at the Accept-header of the request. If that matches with a registered mime type and you have a handler for that mime type, the matching block will be executed. Otherwise, the default rendering method will be invoked.
|
# ? Nov 18, 2012 21:26 |
|
Physical posted:I think that's right. I just recently had a run in with respond_to vs respond_with. I had to do some if/else stuff for a form using ajax and js responders, and respond_with seemed to make more sense and respond_to looks like is deprecated now? respond_with is great for the general case. Best of all, if you're responding with a model that's failed validation: code:
I like to clean up my actions like this: code:
|
# ? Nov 18, 2012 23:28 |
|
Just found a great tutorial for getting started with Ruby on Rails. It's basically a free online class that a Heroku developer / Texas University professor put up: http://schneems.com/ut-rails Apparently it's pretty much the same stuff that he uses to teach his online courses. He even gives exercises.
|
# ? Nov 19, 2012 01:50 |
Two great talks - one on Ruby 1.9 and another focusing on Rails 3 internals: Ruby: * https://www.youtube.com/watch?v=aBgnlBoIkVM Rails: * https://www.youtube.com/watch?v=GRfJ9lni4QA
|
|
# ? Nov 19, 2012 04:27 |
|
Anveo posted:I would just throw the code saving into a job queue as well. Since you are going to be running frequent jobs it will probably be better to use something like sidekiq instead of resque/delayed_job. Thanks, I'm looking into these. As a proof of concept yesterday, I whipped up a node.js/socket.io demo that live-updates a Codemirror widget across multiple sessions. Simple as pie. Porting it to use Juggernaut instead in my existing Rails codebase was also fairly easy. And I've used Resque before (I was actually trying to avoid it), but Sidekiq looks promising. But, where should I keep track of say, "volatile" information about how many (and which) users are connected at any given time? In my node.js example, I just kept a global Javascript object that tracked which clients were connected, and this worked because there was just one instance of that server running that everyone connected to. Obviously storing that kind of data as instance variables in my Rails controller isn't going to work, because all the clients don't share the same instance of that (or are even running in the same process). So where can I put this kind of info? I don't want to keep it in the database because it doesn't need to be that persistent and that seems like a big performance hit. In the Redis keystore, maybe?
|
# ? Nov 19, 2012 15:48 |
|
Flobbster posted:Obviously storing that kind of data as instance variables in my Rails controller isn't going to work, because all the clients don't share the same instance of that (or are even running in the same process). So where can I put this kind of info? I don't want to keep it in the database because it doesn't need to be that persistent and that seems like a big performance hit. In the Redis keystore, maybe? Redis is where I'd put it if I didn't put it in the database. Disk space is cheap, and storing it as a user/entered_at/left_at tuple might give you more freedom in the future.
|
# ? Nov 19, 2012 17:52 |
|
A MIRACLE posted:Two great talks - one on Ruby 1.9 and another focusing on Rails 3 internals: Thanks for linking these. I am a huge fan of JEGII's and these talks gave me some new tricks to play with.
|
# ? Nov 19, 2012 20:29 |
|
I'm looking for a RoR equavilent of the C# "using" statement like seen here http://msdn.microsoft.com/en-us/library/yh598w02.aspxRuby code:
|
# ? Nov 19, 2012 22:46 |
|
tap? http://blog.moertel.com/articles/2007/02/07/ruby-1-9-gets-handy-new-method-object-tap
|
# ? Nov 19, 2012 22:51 |
|
prom candy posted:tap? http://blog.moertel.com/articles/2007/02/07/ruby-1-9-gets-handy-new-method-object-tap It is really hard to search for operands sometimes. "Using statement equivalent ruby on rails" did not really narrow down my search to anything relevant.
|
# ? Nov 19, 2012 23:07 |
|
If anyone doesn't want to use Heroku (see the conversation earlier in the past page or so) AND you already have an updated Ruby/Rails/Phusion Passenger on your cPanel server, then this bash script will definitely help. Basically this will take a lot of the leg work out of configuring a new rails app for cPanel. I have not tried a migration yet, but it should work. It sets up Apache's additional includes for your domain, saves the includes with cPanel, sym links your web path to your rails app, and runs a bundle install that will work correctly with Phusion Passenger. It will modify your Gemfile (2 additional gems that lets it all run: therubyracer and exceljs; no deletions or further modifications), it will not modify your Gemfile.lock. If you already have those 2 gem files included, you will have to go through your Gemfile and remove the extras. Link: https://github.com/Noppadet/cPanel_Phusion_Passenger_mod_rails_setup_script I just tested it on a completely new rails application, and it works great with my server environment (after setting up a controller and root route). If anyone else wants to test on their server environment and let me know how it works, that would be great. On a side note, I did try Heroku. It really seems like more of a headache than setting up my server in this manner, and I won't need to worry about migration in the future (which would pretty much entail this sans cPanel anyway).
|
# ? Nov 20, 2012 03:26 |
|
Knyteguy posted:On a side note, I did try Heroku. It really seems like more of a headache than setting up my server in this manner... I'm really interested to know why you think this. I've used Heroku for a little while now, and set-up is nearly painless. My only complaint is the price associated with it. The bare minimum (after the free tier) is $35.00 a month + whatever add-ons you want to use. I have recently experimented with a VPS or two, and although I got it running properly, it took time (which could have been spent working on the app). At this point I'm comfortable setting up a new server with rvm-capybara + nginx + unicorn, but my god was the documentation to do so fragmented. The cost however is much lower.
|
# ? Nov 20, 2012 04:11 |
|
Physical posted:Thanks, that seems to do what I wanted. Found this too https://gist.github.com/762526 I'm sure from your example that this probably isn't a concern, but keep in mind that tap and using aren't really similar outside of the "locally scoped shorthand variable" sense. There's not really a fixed way of dealing with disposal in Ruby (most things generally have some sort of block-like syntax, but it's purely convention), and you shouldn't expect any cleanup or anything short of the variable being descoped when leaving a tap block.
|
# ? Nov 20, 2012 13:10 |
|
That gist isn't really good Ruby code. The canonical way to do it would be to make the open method take a block argument.Ruby code:
Smol fucked around with this message at 22:28 on Nov 20, 2012 |
# ? Nov 20, 2012 22:25 |
|
Oh My Science posted:I'm really interested to know why you think this. I've used Heroku for a little while now, and set-up is nearly painless. My only complaint is the price associated with it. The bare minimum (after the free tier) is $35.00 a month + whatever add-ons you want to use. I was basically running into some problems with their toolbelt, and IronRuby. I'm not sure if their toolbelt came with IronRuby, or if it's the version of IronRuby I downloaded. I couldn't find any information on the error via Google, or their forum and basically called it quits. I had already set up my server environment, thinking that Heroku had no free tier. Basically it came down to debugging IronRuby, and the Heroku system after working for 4 hours debugging my own server, or just using what I had just spent a good chunk of time setting up. Plus like you mentioned it's pretty cheap running a VPS, especially because I already rent one for my small hosting business.
|
# ? Nov 21, 2012 06:51 |
|
Knyteguy posted:I was basically running into some problems with their toolbelt, and IronRuby. The toolbelt does some odd things I don't care for I'll admit, but I don't think it has anything to do iron ruby.
|
# ? Nov 21, 2012 07:54 |
|
I have a table with pre-existing data in MySql used by a rails app. I want to add a new column (article_slug) that needs to be unique and ideally also has a database index for fast lookup. The pre-existing data needs to remain there, but it won't ever be affected by the new logic. Is there a reasonable way to have my constraint and index only apply to *new* records, or do I have to go back and make an article_slug for the old entries?
|
# ? Nov 21, 2012 18:54 |
|
Can anyone recommend a free SMTP mail server I can use with my own domain? Just something for contact forms.
|
# ? Nov 21, 2012 19:45 |
|
The Sweetling posted:Can anyone recommend a free SMTP mail server I can use with my own domain? Just something for contact forms. Try Mandrill. I'd think 12,000 sends a month should meet your needs.
|
# ? Nov 21, 2012 20:28 |
|
Lexicon posted:I have a table with pre-existing data in MySql used by a rails app. I want to add a new column (article_slug) that needs to be unique and ideally also has a database index for fast lookup. Have you just tried creating the unique constraint? It might work. While I'm not entirely sure for mysql, in postgres null != null, so unique constraints "ignore" the nulls. I know it's not the case for oracle though, but I'd imagine mysql is more sane wrt null.
|
# ? Nov 21, 2012 20:57 |
|
Molten Llama posted:Try Mandrill. I'd think 12,000 sends a month should meet your needs. Dope, thanks!
|
# ? Nov 21, 2012 22:06 |
|
Pardot posted:Have you just tried creating the unique constraint? It might work. While I'm not entirely sure for mysql, in postgres null != null, so unique constraints "ignore" the nulls. I know it's not the case for oracle though, but I'd imagine mysql is more sane wrt null. NULL != NULL because in SQL, NULL represents an unknown value, not just an nonexistant value, like nil in Ruby. If think of the question, "Is unknown a equal to unknown b?", it should be fairly clear you don't know the answer the question. Similarly, the answer to "Is unknown a not equal to unknown b?" is unknown as well. You should use the the special IS NULL or IS NOT NULL operators to check if a value is or isn't NULL. Smol fucked around with this message at 00:12 on Nov 22, 2012 |
# ? Nov 22, 2012 00:04 |
|
Yeah, I wasn't clear but I was saying postgres treats null correctly, I assume msyql is also probably correct (so he should be able to create the unique constraint no problem), and oracle is nuts and incorrectly treats null == null == ''
|
# ? Nov 22, 2012 00:23 |
|
Thanks, worked great! On an unrelated note, is it considered bad form for a mixin to presume the existence of methods/variables in classes which include it? e.g. code:
|
# ? Nov 22, 2012 01:14 |
|
Lexicon posted:Thanks, worked great! It's not bad form. Enumerable does this. Don't bother validating, the interpreter will do that for you (by raising NoMethodError) when you try and call a nonexistent method. Document your dependency, and if another developer fucks it up well it's kind of their fault.
|
# ? Nov 22, 2012 05:20 |
|
|
# ? May 31, 2024 23:37 |
|
Is there an alternative for Mercury Editor? I think this is over kill for what I want to do. I just want to provide some buttons for users to markup a blog post. Or am I better off creating my own with red carpet?
|
# ? Nov 22, 2012 08:03 |