|
I want to set up a model that can have many self-referential relationships. Basically, I have a population of artists that are generally related to each other in some way. If I was just trying to track who each person's parents were, I could track this by just doing something like this: code:
What is the right way to do this? Should I set up a separate Relationship model that defines and stores the relationship_type, then have the Artist model refer to that? EAT THE EGGS RICOLA fucked around with this message at 23:53 on Nov 12, 2013 |
# ? Nov 12, 2013 23:47 |
|
|
# ? Jun 5, 2024 04:20 |
|
You might want to look at using something like awesome_nested_set for that.
|
# ? Nov 14, 2013 05:23 |
|
prom candy posted:You might want to look at using something like awesome_nested_set for that. This is perfect for the hierarchy, but what would you say is the best way to define the relationship type? One person might have a half dozen child/parent/sibling nodes related to it, and I can use a helper or simple code in the view to figure out who is who in a simple family structure (kids and parents are obvious, nephews and nieces are just the children of siblings, etc) but what would I do if adopted kids, spouses, or roommates enter the picture? EAT THE EGGS RICOLA fucked around with this message at 03:44 on Nov 15, 2013 |
# ? Nov 15, 2013 03:40 |
|
Is there a way I can manually execute the validtors that are listed on a model using the validates(*attributes) method? I can get a list of them using Model.validators, but how would I then easily apply those to the instance I have? I want to skip the ones that use the validates_with clause and only run the ones that do validates(*args) e.g. Ruby code:
ee: Here's my current dilema: how do I move this code to a module? Currently this doesn't work. eee: add included do to the module, this seems to work. Ruby code:
Ruby code:
KoRMaK fucked around with this message at 16:58 on Nov 15, 2013 |
# ? Nov 15, 2013 15:39 |
|
Hey, I'm trying to write my first RSpec tests, and I don't know Ruby very well at all. I'm using WebMock to simulate some http requests. The application I'm testing should send a request that contains a list of attributes in the format "request=attr1,attr2,attr3,...", in no particular order after the equals sign. I want to test that all the required attributes are present. stub_request only accepts a single .with call, and as far as I can tell that's the only way to check the content of the body of the request. Preferably I could get the content of the request as a string that I could check myself, but I'm not sure if that's possible. Right now, I have a shared example for the structure of the request, and then a bunch of little describes for each attribute. code:
edit: WebMock lets you set up a custom callback on making a request, this looks like the answer code:
a slime fucked around with this message at 22:56 on Nov 15, 2013 |
# ? Nov 15, 2013 22:34 |
|
EAT THE EGGS RICOLA posted:This is perfect for the hierarchy, but what would you say is the best way to define the relationship type? One person might have a half dozen child/parent/sibling nodes related to it, and I can use a helper or simple code in the view to figure out who is who in a simple family structure (kids and parents are obvious, nephews and nieces are just the children of siblings, etc) but what would I do if adopted kids, spouses, or roommates enter the picture? Oh you're like literally making a family tree app? You'll probably want a relationships table as you mentioned then. Eventually you may want to be able to add comments and other info to individual relationships as well.
|
# ? Nov 16, 2013 06:39 |
|
Bit confused about how require works. I've got some files required in a spec_helper file. Then I require_relative that spec_helper file in a model_spec file. But the files that were required in the helper aren't loaded in the model_spec. However if I manually require the files in the model_spec everything is fine. Is that supposed to work that way? ie. not being able to have chains of requires across files. e. for reference this is in ruby 2.0, rails 4.0.1 Sil fucked around with this message at 05:38 on Nov 17, 2013 |
# ? Nov 17, 2013 05:15 |
|
I'm trying to incoporate facebook login via omniauth with devise. Users can login via facebook, but it broke the regular devise login. I'm getting a wierd error when a user does the ole devise loginRuby code:
I have created a sessions_controller.rb that inherits from Devise::SessionsController but it looks like it is not overriding the gemmed version that comes with devise. How do I override the sessions_controller? I set the routes for it to this ruby posted:devise_for :users, :controllers => {:sessions => "sessions"} I also have tried overrideing require_no_authentication in the sessions_controller.rb but it never seems to called. e: drat, I forgot the s in :controllers KoRMaK fucked around with this message at 18:23 on Nov 19, 2013 |
# ? Nov 19, 2013 18:17 |
|
prom candy posted:Oh you're like literally making a family tree app? You'll probably want a relationships table as you mentioned then. Eventually you may want to be able to add comments and other info to individual relationships as well. I didn't really intend to make a family tree app at first, but I guess that's what makes the most sense now. Thanks!
|
# ? Nov 19, 2013 18:20 |
|
KoRMaK posted:I'm trying to incoporate facebook login via omniauth with devise. Users can login via facebook, but it broke the regular devise login. I'm getting a wierd error when a user does the ole devise login What directions are you following for using omniauth with devise? I have a working devise + omniauth (for facebook, google, etc) and I don't have my sessions controller overridden. The only things I've done is add an ominauth callbacks controller and the configuration to config/initializers/devise.rb
|
# ? Nov 19, 2013 19:52 |
|
kayakyakr posted:What directions are you following for using omniauth with devise? I have a working devise + omniauth (for facebook, google, etc) and I don't have my sessions controller overridden. It doesn't talk about devise, so I'm filling in those gaps myself and with this gist https://gist.github.com/schleg/993566 Maybe I should follow this guide https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview KoRMaK fucked around with this message at 21:19 on Nov 19, 2013 |
# ? Nov 19, 2013 21:15 |
|
I'm going to be mentoring at the Ladies Learning Code Ruby event in Toronto this Saturday. Come and say hi if you're there as a mentor or a student, I'll be the white nerdy guy with glasses. And if anyone knows any women who are interested in learning to code you should tell them about this event (or other LLC events) as they're apparently really good!
|
# ? Nov 19, 2013 21:42 |
|
KoRMaK posted:Maybe I should follow this guide https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview That's the one.
|
# ? Nov 19, 2013 23:03 |
|
prom candy posted:I'm going to be mentoring at the Ladies Learning Code Ruby event in Toronto this Saturday. Come and say hi if you're there as a mentor or a student, I'll be the white nerdy guy with glasses. And if anyone knows any women who are interested in learning to code you should tell them about this event (or other LLC events) as they're apparently really good! Awesome! I'm mentoring there too. It is a really awesome event, Dessy (the instructor) does an amazing job with the course. I'll try to find you. (white nerdy guy with glasses is a bit of a broad category with LLC mentors..)
|
# ? Nov 20, 2013 13:12 |
|
Sweet, I have devise and facebook login working side by side. I had to override registrations and sessions to handle the two properly. New question: how do I keep heroku from taking forever when doing the assets:precompile step? I added ckeditor to my vendor/javascripts folder and I am pretty sure that is what is taking it so long. I never change the files in that directory, so why does it precompile on each push? I want it to only precompile if there are differences. In case anyone here wants to check out what I've been working on, you can find it at http://marquee.liquid-software.com It lets you create conversation threads connected to any gps location. Kind of like yelp, but instead of being tied to a business you can tie it to any arbitrary location.
|
# ? Nov 20, 2013 17:18 |
|
KoRMaK posted:Sweet, I have devise and facebook login working side by side. I had to override registrations and sessions to handle the two properly. try: https://github.com/ndbroadbent/turbo-sprockets-rails3
|
# ? Nov 20, 2013 18:07 |
|
enki42 posted:Awesome! I'm mentoring there too. It is a really awesome event, Dessy (the instructor) does an amazing job with the course. I'll try to find you. (white nerdy guy with glasses is a bit of a broad category with LLC mentors..) Cool! Yeah the white nerdy guy with glasses was kind of a joke, I assume there'll be a few of us who fit that profile. Just awkwardly ask everyone if they have stairs in their house, it's the only way. Have you mentored before? What's it like? I don't really know what to expect.
|
# ? Nov 21, 2013 05:51 |
|
Teaching/Mentoring is awesome, but tough. Don't be too depressed if you fail miserably the first time you give it a go. Keep doing it if you can - finding simple ways to explain complicated subjects is one of the best ways to deepen your own understanding of the subject at hand.
|
# ? Nov 22, 2013 15:22 |
|
It should be pretty interesting! The class has a dedicated teacher and a prepared lesson plan, so I think the mentors are just meant to wander and answer questions or help people who are stuck. I do a decent amount of mentoring at work but I haven't work with people who don't code at all before.
|
# ? Nov 22, 2013 18:07 |
|
I'm comfortable with rails, but I feel like my ruby knowledge is lacking. Is there any recent material about the language that isn't aimed at people new to programming? A book would be good. I want to know how classes, modules, closures, etc. work in ruby without googling each individual term as I remember that I want to learn about it, as that'll leave me with holes that I want to fill in. Basically "oh, you already know some other language well? here's everything you should know about ruby!" I'd like to get up-to-speed quickly. Basically, I'll be setting up something with Shopify's active_merchant to handle payments for the main product we're working on, and I'll doing something similar with Stripe's Abba, so it won't be extremely complicated, but I'd feel more comfortable if I had more Ruby knowledge. Also, our operations guy would really like to have this done on a windows environment. The brief reading I've done suggests that ruby is much slower on Windows (though JRuby helps, kind of), that permissions will be a pain in the rear end, and that I can expect to have a hard time finding support* for any problems that may pop up because pretty much everyone talking about ruby online is not using Windows. Pro to Ruby on Windows: - Our server guy knows Windows really well, doesn't know anything about linux <-- This is the main issue Con to Ruby on Windows: - People online think it sucks, so as the only developer here with Ruby experience, if something stumped me, I could have trouble getting advice online? The only linux experience I have is from using and developing on ubuntu day-to-day in my personal time. It seems like it makes sense to go with Windows, so that we have someone who actually understands the environments we'll be running it on. His time is more expensive than mine as well, so it makes more sense for me to spend time grappling with any Windows-Ruby issues that come up than it does for him to spend time figuring out redhat or something. Safe and Secure! fucked around with this message at 20:46 on Nov 23, 2013 |
# ? Nov 23, 2013 20:26 |
|
Safe and Secure! posted:Basically "oh, you already know some other language well? here's everything you should know about ruby!" I liked "The Well-Grounded Rubyist" when I was getting started. It still starts out pretty basic but it doesn't waste much time with it before getting into all the gritty details. It's a pretty good reference too that I still go back to when I'm looking for something.
|
# ? Nov 23, 2013 20:33 |
|
Obsurveyor posted:I liked "The Well-Grounded Rubyist" when I was getting started. It still starts out pretty basic but it doesn't waste much time with it before getting into all the gritty details. It's a pretty good reference too that I still go back to when I'm looking for something. Going from the amazon comments, that looks like exactly what I'm looking for. Thanks!
|
# ? Nov 23, 2013 20:49 |
|
Safe and Secure! posted:I'm comfortable with rails, but I feel like my ruby knowledge is lacking. Is there any recent material about the language that isn't aimed at people new to programming? A book would be good. If you're deploying to Windows, JRuby is your only real choice. MRI sucks balls and it is even worse on Windows. The good news is that if your shop has any kind of Java infrastucture, deploying JRuby apps is trivial. Warbler can create a .war file for you that you can deploy on any Servlet container, so in theory, the ops guys don't need to know anything about Ruby or JRuby. JRuby does still have some string encoding problems on Windows (because most of the JRuby users and developers use Linux or OS X), but they're getting ironed out. Smol fucked around with this message at 21:46 on Nov 23, 2013 |
# ? Nov 23, 2013 20:55 |
|
That's great, our product is basically a pile of JSP running on a Tomcat server. So it doesn't sound like a horrible idea to go with Windows (and JRuby), then?
|
# ? Nov 23, 2013 21:06 |
|
Nope. And anyways, if you run into any problems or have any further questions, feel free to give me a shout here or on #jruby at freenode.
|
# ? Nov 23, 2013 21:26 |
|
Thanks!
|
# ? Nov 23, 2013 21:38 |
|
Just be aware, you're going to have a bad time with gems that rely on C extensions. But fortunately, most of the widely used ones (e.g. database drivers, nokogiri for xml parsing) have direct JRuby ports or more-or-less equivalent alternatives, so in most cases, it's not a big issue. But there is a significant number of gems that you simply might not be able to use because of this. And of course, you'll be able to leverage the JVM ecosystem as well. Using Java libraries in JRuby is easier than using them in Java.
Smol fucked around with this message at 21:54 on Nov 23, 2013 |
# ? Nov 23, 2013 21:51 |
|
There were a couple issues I ran into while trying to run my dev environment on windows and I eventually just jumped into running my own linux VM. I'm glad I did it. Linux isn't that scary and the gnome desktop is basically OSX. I like it alot now, and I've learned so much and I was able to learn at my own pace.
|
# ? Nov 23, 2013 22:41 |
|
KoRMaK posted:There were a couple issues I ran into while trying to run my dev environment on windows and I eventually just jumped into running my own linux VM. I'm glad I did it. Linux isn't that scary and the gnome desktop is basically OSX. I like it alot now, and I've learned so much and I was able to learn at my own pace. I did this too, I got so annoyed trying to run everything in windows that I eventually just gave up and did everything in either OSX or a linux VM.
|
# ? Nov 23, 2013 23:27 |
|
Programming in Ruby helped me decide to make the permanent switch to Linux. Haven't looked back.
|
# ? Nov 24, 2013 01:33 |
|
Whatever OS you use for development, it's worth running your dev environments in virtual machines that are as close to the production environment as possible. Tools like vagrant coupled with something like chef or puppet make this really easy, not to mention how much they help in setting up and maintaining your production environments.
|
# ? Nov 24, 2013 02:42 |
|
Yep. That works. From 600 seconds down to 6 seconds. Thanks. Since I'm on heroku I had to add the builder pack to my app.
|
# ? Dec 1, 2013 23:23 |
|
Apologies if this is the wrong place to ask this. I have basically no knowledge of programming (like, I knew Java and Visual Basic in middle school, but haven't programmed in the last seven years). Now though, I want to make a web-app (I think) that would basically just let people submit forms on a site, and then spit out a generic email response. I have a good three months to do this, and want to figure it out myself. Would Ruby on Rails be a good way of doing this, and if so, what are some good resources for getting started? At the moment I'm using codeacademy's Ruby track, that teaches poo poo like "what the hell does && do". I'm also taking CS 101 online from Stanford, that is basically "what is a program". Beyond that though, I'm not sure how to best go about teaching myself. Should I get a dummies book? Are there online resources I'm missing? I'd love help, thanks a lot. e: Should I learn Python first like the FAQ suggests, or would I be ok going straight into Ruby?
|
# ? Dec 2, 2013 01:04 |
|
foutre posted:Apologies if this is the wrong place to ask this. I have basically no knowledge of programming (like, I knew Java and Visual Basic in middle school, but haven't programmed in the last seven years). Now though, I want to make a web-app (I think) that would basically just let people submit forms on a site, and then spit out a generic email response. Ruby on Rails is indeed a good language for what you want to do. Fairly easy to learn and has a good bit of hand-holding for beginners once you grasp a few concepts of the Rails conventions. I used O'Reilly Rails Cookbook for my first book, but I'm more of a get it started and learn as I go kind of person, so I moved beyond the book pretty quickly. There should be some other suggestions coming shortly, though.
|
# ? Dec 2, 2013 01:09 |
|
foutre posted:Apologies if this is the wrong place to ask this. I have basically no knowledge of programming (like, I knew Java and Visual Basic in middle school, but haven't programmed in the last seven years). Now though, I want to make a web-app (I think) that would basically just let people submit forms on a site, and then spit out a generic email response. Michael Hartl's Ruby on Rails Tutorial would probably be a really good place for you to start. It has you built out a simple web app (basically a Twitter clone last time I used it but it could have changed). This would probably give you a good base to understand all of the pieces of Rails put together for a full app. For such a simple app like you are suggesting it might just be easiest to dive straight in to Rails and trying to implement it rather than trying to build more of a foundation first. If you really want to keep going with programming learning more about Ruby or Python would definitely be a good place to start and keep going what you are doing.
|
# ? Dec 2, 2013 19:39 |
|
Thanks a lot, I'll try both. I like the idea of just jumping in and figuring things out along the way -- I'll probably be back here with problems though. Both of these also seem a lot better than codecademy. That was getting to be a little much.
|
# ? Dec 2, 2013 21:17 |
|
foutre posted:Thanks a lot, I'll try both. I like the idea of just jumping in and figuring things out along the way -- I'll probably be back here with problems though. Both of these also seem a lot better than codecademy. That was getting to be a little much. I'll second that tutorial with the only caveat is that people tend to not read it 100% and get stuck on things here or there, or have problems with setting Rails up which can be a little confusing the first few times you do it. It's easy to get the wrong version of a Gem or start out with the wrong version of Ruby and have weird stuff not work. But once you get going, you should be able to run through that tutorial in a few days to a week depending on how much time you can put into it. Whether or not you should do all the 'tests' for the code is debatable (not tests like a quiz but code tests, it's a programming thing) and will take up most of the time. But once you're halfway through the book you could make a website where you can 'enter forms and get email responses' in a few hours. It's very powerful stuff.
|
# ? Dec 8, 2013 02:14 |
|
Well, as a proof of concept with bogus data entries, I have the web app up and running on Heroku. One thing I'm facing now is that to go live, I'll need to import my beer data set into the database. This means ~200,000 unique beers and ~14,000 breweries. This puts me into two options with Heroku: 1) $9/month - Hobby databases are designed for trial, development, testing, and basic usage for hobby apps. Hobby databases are not suited for production. Up to four hours of downtime per month. 2) $200/month - Tengu - 1.7GB RAM - 256GB storage - 200 connections That escalates quickly. Are the other hosting options for long but not wide databases?
|
# ? Dec 12, 2013 18:29 |
|
raej posted:Well, as a proof of concept with bogus data entries, I have the web app up and running on Heroku. They have another tier under standard for $50/month. But in all honesty, you could probably use their hobby level $9 database and be ok. Other options: - There's a heroku add-on that will give you a 1GB mysql db with claimed 100% uptime for $10/month. - Could use AWS free tier for their sql-style database (think it has a 250 MB allowance). - Could set up a $5/month small instance on DigitalOcean, install your own database, and open it up to connections from Heroku.
|
# ? Dec 12, 2013 19:03 |
|
|
# ? Jun 5, 2024 04:20 |
|
kayakyakr posted:- Could set up a $5/month small instance on DigitalOcean, install your own database, and open it up to connections from Heroku. I would recommend this highly. DigitalOcean is phenomenal. (Heck, you could just put your app there, too.)
|
# ? Dec 12, 2013 19:13 |