|
Are you calling include inside a method definition? I don't think you can do that. It should work at the top level or as part of a Module/Class definition though. But you don't have to use include. For example, if your TestModule contains a class called TestClass, you could use either: code:
code:
|
# ? Dec 22, 2011 17:31 |
|
|
# ? May 15, 2024 08:01 |
|
That is assuming that lib/test_module.rb looks like this:code:
|
# ? Dec 22, 2011 17:34 |
|
Mental Filler posted:So you have to require the file and then include the contents? That makes sense. Kernel.load reads a file and executes its contents. Kernel.require returns false if the file has been required already. If it hasn't been require, it loads it, adds it to the list of required files, and returns true. require also automatically puts .rb at the end of the file name for you. Module.include adds the instance methods from the given Module to the current Module. For example: code:
code:
|
# ? Dec 22, 2011 17:39 |
|
If it's still not solved, just cut the the chase and post your loving code instead of making us infer what you're doing.
|
# ? Dec 22, 2011 18:03 |
|
hepatizon posted:post your loving code "I can't, it's company proprietary/Secret/PHI/has been found to cause cancer in California." Make a reduced case that exhibits the same problems that you can make public. Making the reduced case will also help you reason about the specific problem instead of general malaise about your codebase.
|
# ? Dec 22, 2011 18:11 |
|
the problem was trying to use include inside a method. Sorry folks, I didn't mean to draw out what is a pretty dumb issue. Thanks for the advice, I'm still new to ruby so it's little things like this that have been tripping me up.
|
# ? Dec 22, 2011 18:37 |
|
Has anybody here stopped using RVM in favor of rbenv? Any thoughts on the experience? Seeing the 20+ gemsets I have (one for each project!) has made me reconsider my continued use of RVM.
|
# ? Dec 29, 2011 22:04 |
|
Deus Rex posted:Has anybody here stopped using RVM in favor of rbenv? Any thoughts on the experience? Seeing the 20+ gemsets I have (one for each project!) has made me reconsider my continued use of RVM. I haven't had any problems with rbenv, and have been using it since August and recommending it since September. Even when I did use rvm I didn't use gemsets; bundler handles different gems for different projects quite well.
|
# ? Dec 29, 2011 22:12 |
|
When you recommend it, what do you list as its advantages?
|
# ? Dec 30, 2011 04:18 |
|
Doc Hawkins posted:When you recommend it, what do you list as its advantages? Conceptually simpler, fewer features, no garish ascii art, shims work predictably in non-shell situations, doesn't block shells when you change directories out of some misplaced concept of "trust," doesn't randomly break due to un-tested midday patches. And these are just the problems I've had.
|
# ? Dec 30, 2011 04:32 |
|
Most important question: how do you pronounce it? (I'm partial to "ruh-BENV")
|
# ? Dec 30, 2011 04:50 |
|
Doc Hawkins posted:Most important question: how do you pronounce it? (I'm partial to "ruh-BENV") I say "are-bee-env."
|
# ? Dec 30, 2011 06:23 |
|
Doc Hawkins posted:Most important question: how do you pronounce it? (I'm partial to "ruh-BENV") <sam> I personally say r-b-env <sam> to cause confusion with rvm <sam> josh peek says ruby-env
|
# ? Dec 30, 2011 06:37 |
|
I switched. The only thing I don't like is that you have to do rbenv rehash after you install a gem with binaires. Also I've been saying arby env, but I like rue benv, so I'm going to start saying that now. Also also rspec is respek
|
# ? Dec 30, 2011 07:15 |
|
Pardot posted:I switched. The only thing I don't like is that you have to do rbenv rehash after you install a gem with binaires. rspec is trash Newish project uses the default rails 3 minitest setup without even using shoulda and it's rather good.
|
# ? Dec 30, 2011 14:28 |
|
BonzoESC posted:rspec is trash Them's fighting words! Really though, I've only really ever used rspec, and I like it just fine, particularly once I grokked using subjects, contexts, and it a lot better. What does the newish stuff bring to the table? Now cucumber, there's a thoroughly useless test framework.
|
# ? Dec 30, 2011 14:36 |
|
enki42 posted:Them's fighting words! I never liked rspec because I always had problems figuring out where underscores should go in should_not be_nil-type situations, and shoulda got me 90% of what subjects and contexts did. MiniTest::Unit is just classic Test::Unit but a better implementation; it feels nicely straightforward with very little clever stuff happening under the hood. Also, I like cucumber because I can mash out a high-level view of what I want working with the site to be without giving a flying gently caress about implementation, and I generally don't have to change the feature file once it's written; just implement steps and focus on changing failure messages or making it pass.
|
# ? Dec 30, 2011 16:17 |
|
BonzoESC posted:Also, I like cucumber because I can mash out a high-level view of what I want working with the site to be without giving a flying gently caress about implementation, and I generally don't have to change the feature file once it's written; just implement steps and focus on changing failure messages or making it pass. I find I can do the same with integration tests written in rspec - you get most of what you need with the capybara DSL and some sort of fixture loading / factories. Adding the seperation between test definition and implementation always felt like an unnecessary step that made grokking the tests more complicated, in my mind. And yeah, I do agree that even if you understand how rspec works, most of it is just memorization about how you should structure things rather than reasoning about the system.
|
# ? Dec 30, 2011 17:09 |
|
BonzoESC posted:I never liked rspec because I always had problems figuring out where underscores should go in should_not be_nil-type situations, and shoulda got me 90% of what subjects and contexts did. The problem I had with rspec is that the syntax is quite a bit magic. You basically have to know how rspec works (matchers etc) to actually be able to use it, where with something like Test::Unit, it's very obvious how to use the API. I used to hate on rspec, but I started using it for a project I've been working on since August and it's been a pleasure so far, and I like subject(), etc. I've also gone back and forth on Cucumber. On previous projects, it was already setup with webkit-capybara, and all the parts were working together. On this app I've been working on, I started to use it and then gave up trying to get all the pieces to work. Fast-forward 4 months and I've gone back to writing Cucumber tests, if anything to make sure the app is working front to back. Writing controller tests for RESTful controllers that use decent_exposure seems like kind of a waste, since each action is basically "respond_with some_model" Edit: Also this is a really good read: http://blog.steveklabnik.com/posts/2011-12-30-active-record-considered-harmful manero fucked around with this message at 17:20 on Dec 30, 2011 |
# ? Dec 30, 2011 17:14 |
|
enki42 posted:I find I can do the same with integration tests written in rspec - you get most of what you need with the capybara DSL and some sort of fixture loading / factories. Adding the seperation between test definition and implementation always felt like an unnecessary step that made grokking the tests more complicated, in my mind. Keeping them separated means you can decide what you want long before you even think about how to test it, let alone implement it: code:
The key is that I'm not using the web_steps file from old versions of cucumber, so I don't have to worry about formulating the features to conform to that, and as a result I can make When I create a blog a nice high-level step instead of a laborious set of And I fill in 'butts' with 'dicks' steps.
|
# ? Dec 30, 2011 17:26 |
|
I understand, conceptually, that Bundler is supposed to act as a sort of 'virtualenv' for Ruby projects, and that it works alongside rbenv for this purpose, but I've never seen a setup of it in action (i.e., two projects, with different dependencies, and switching between them). Does anyone have anything useful to point me to to learn how to use it? The official webpage feels kind of sparse and after reading it a time or two I'm still no closer to understanding how to use it.
|
# ? Dec 30, 2011 17:40 |
|
Fren posted:I understand, conceptually, that Bundler is supposed to act as a sort of 'virtualenv' for Ruby projects, and that it works alongside rbenv for this purpose, but I've never seen a setup of it in action (i.e., two projects, with different dependencies, and switching between them). Does anyone have anything useful to point me to to learn how to use it? The official webpage feels kind of sparse and after reading it a time or two I'm still no closer to understanding how to use it. Prefix commands with bundle exec to run them with the current bundle. alias be="bundle exec" will save time, as will bundle exec $SHELL
|
# ? Dec 30, 2011 17:53 |
|
Fren posted:I understand, conceptually, that Bundler is supposed to act as a sort of 'virtualenv' for Ruby projects, and that it works alongside rbenv for this purpose, but I've never seen a setup of it in action (i.e., two projects, with different dependencies, and switching between them). Does anyone have anything useful to point me to to learn how to use it? The official webpage feels kind of sparse and after reading it a time or two I'm still no closer to understanding how to use it. Not what you asked, but since you mentioned virtualenv I want to point out that bundler is 2 things. First virtualenv from python, but secondly a dependency resolver. It's easiest to show an example of the latter. Let's say your project depends on library A and B. Library A depends on library Y version >= 1.0 and <= 1.1 Library B depends on library Y version >= 1.1 Library Y has versions 1.0, 1.1, and 1.2 Obviously version 1.1 should be used. However, without bundler if library B gets loaded first, it will grab version 1.2, and then library A is hosed. Bundler figures out all of the dependencies ahead of time, resolves situations like that, and then locks them down to the specific versions.
|
# ? Dec 30, 2011 18:16 |
|
BonzoESC posted:Prefix commands with bundle exec to run them with the current bundle. alias be="bundle exec" will save time, as will bundle exec $SHELL put this code from sam stephenson in your shell code:
code:
|
# ? Dec 30, 2011 20:51 |
|
I'll be looking at adding a cart to an existing clients site, and I would appreciate some feed back regarding spree. If I need a highly customized look, is spree simple enough to bend to my will? I took a look at the documentation, and they recommended against replacing the entire theme manually due to issues caused by future upgrades. Also, is there anything else I should be looking at in terms of rails e-commerce. Spree seems to offer what the client wants, but I am eager to learn how to do this myself. Considering time is not an issue, are there some good (current) resources regarding creating your own simple(?) carts? To clarify this is for an artists site, and all they really want to do is sell prints from their online portfolio. Ideally it would be nice to have the option of adding pieces to a store when they are uploaded to the portfolio, and define print size, prices, etc. all at the same time. I need to be schooled in e-commerce please.
|
# ? Dec 31, 2011 09:41 |
|
Synchronization woes I'm writing a Rails app that's similar to sites out there like Codepad and ideone that lets users submit code snippets to be compiled, executed, and view the output, but with some extra features I need. To prevent a large number of users from launching a ton of processes at once, I created a fixed number of threads that wait on a queue for jobs to run, and used AJAX to poll the server to find out when results were ready. (Implementation note: Rather than use the built-in Queue class, I wrote my own queue using a mutex and condition variable because I needed to be able to prioritize jobs. I'm 100% confident that the behavior I'm seeing below is not due to bugs in this.) This worked fine under Mongrel development, but when I moved the app over to nginx, this technique failed, because the requests occur in separate worker processes, because the process signaling the condvar isn't the one that started the job threads. How can I make this work in a multi-process production environment? I want as lightweight a solution as possible -- I don't *need* to store these jobs or their results in the database, so I've avoided using the various job-queue gems out there. I suppose I can create a table for these jobs if the database is the best place to handle synchronization, but if that's the case, how do I have my worker threads wait for a row to appear in the table and make sure that no race conditions result when one thread takes a row and deletes it?
|
# ? Dec 31, 2011 18:50 |
|
Flobbster posted:How can I make this work in a multi-process production environment? I want as lightweight a solution as possible -- I don't *need* to store these jobs or their results in the database, so I've avoided using the various job-queue gems out there. I suppose I can create a table for these jobs if the database is the best place to handle synchronization, but if that's the case, how do I have my worker threads wait for a row to appear in the table and make sure that no race conditions result when one thread takes a row and deletes it? Just use resque and store results in the database for 24 hours or something.
|
# ? Dec 31, 2011 19:01 |
|
BonzoESC posted:Just use resque and store results in the database for 24 hours or something. Seconding resque. It's ridiculously easy to get setup and running.
|
# ? Dec 31, 2011 19:03 |
|
Thanks! Resque hadn't come up in my searches but it looks like it may be a good solution to my problem, checking it out now.
|
# ? Dec 31, 2011 19:13 |
|
Alternatively suggesting https://github.com/ryandotsmith/queue_classic to avoid an extra dependency. I've pushed a lot of jobs through it quote:select id from queue_classic_jobs limit 1;
|
# ? Dec 31, 2011 21:28 |
|
Pardot posted:Alternatively suggesting https://github.com/ryandotsmith/queue_classic to avoid an extra dependency. That looks boss as hell; forwarding it to some people since I assume it works on Heroku Ronin. Edit: "queue_classic handles over 3,000,000 jobs per day. It does this on Heroku's Ronin Database."
|
# ? Dec 31, 2011 23:08 |
|
I posted this in the Android thread, but I think it might fit better here, so I'm reposting it. I just finished the functional part of my first android application. I wrote three applications to get my idea to work. The first is a java web app, it grabs information from a website and puts it into a database on my hosted web server. The second is the web server, it is a ruby on rails application that just gives me basic REST and CRUD functionality. The third application is the android app, it grabs the information from my web server and then presents it in a easily readable format. This is the first time I've ever done web development. My question is, how do I protect this information I've gathered on my web server, but still allow all the android devices to access it? What are the best practices I should be using, should I use encryption, authentication or both? Should I just set up one username and password that every devices uses? What should I do, so only my one web app can make modifications and not give that access to the devices? After reading a little more and getting one response in the android thread, I think I should require authentication/authorization for creating/updating/deleting records on my webserver. I should make the reading public, but use some type of encryption, so only my android application can decrypt the data. Does that sound like a good route to go? If so, does anyone have suggestions for authentication/authorization and encryption/decryption?
|
# ? Jan 3, 2012 02:27 |
|
Frog Face posted:Does that sound like a good route to go? If so, does anyone have suggestions for authentication/authorization and encryption/decryption? What are you trying to do again? Will users have to have accounts with your web service? That's authentication and authorization. Will you use HTTPS? That's encryption. Will you use encryption for at-rest data? Don't, it's a waste of time.
|
# ? Jan 3, 2012 20:01 |
|
If any of you are going to be in SF next week you should come to the heroku conference http://waza.heroku.com/
|
# ? Jan 3, 2012 21:32 |
|
I'm so there.
|
# ? Jan 3, 2012 21:34 |
|
Topics look great, hopefully they post videos
|
# ? Jan 3, 2012 21:46 |
|
atastypie posted:Topics look great, hopefully they post videos I just asked and we're recording a bulk of them.
|
# ? Jan 3, 2012 22:30 |
|
Pardot posted:I just asked and we're recording a bulk of them.
|
# ? Jan 4, 2012 05:03 |
|
BonzoESC posted:What are you trying to do again? In a nutshell, I want some one with my android app to have access to the records, but I don't want it to be accessible with just a browser, or any means other than my app. Then on top of that, I want the apps to just be able to read the records. I have another app, that I want to have creation/update/deletion capabilities. Frog Face fucked around with this message at 05:15 on Jan 4, 2012 |
# ? Jan 4, 2012 05:07 |
|
|
# ? May 15, 2024 08:01 |
|
Frog Face posted:In a nutshell, I want some one with my android app to have access to the records, but I don't want it to be accessible with just a browser, or any means other than my app. Then on top of that, I want the apps to just be able to read the records. I have another app, that I want to have creation/update/deletion capabilities. To keep out browsers, run the android app over https with http basic authentication and a hardcoded password. The https means that people will have to take five minutes to unzip and strings the apk to get your hardcoded password instead of thirty seconds to use wireshark. Assuming the CRUD app is for your use only, just use a different http basic auth password and don't share it.
|
# ? Jan 4, 2012 06:10 |