|
kayakyakr posted:I also believe that it falls through (or fails to do so). So if you have success.json on the first line and then success.all on the second line, it'll respond with the json line and not the all line. Can I do any magic with that or do I have to build a separate function and call it from each success.whatever call?
|
# ? Feb 3, 2014 23:06 |
|
|
# ? Jun 3, 2024 22:25 |
|
I have started looking for a junior rails dev position and it seems like a lot of them require Angular experience now. Having very little experience with it I'm not sure where to get started here. I have created the basic hello world angular + rails api app but I imagine they want a little more exposure than that. Can a more experienced rails dev tell me what kind of demo app / project I should work on to impress potential employers?
|
# ? Feb 3, 2014 23:41 |
|
Oh My Science posted:I have started looking for a junior rails dev position and it seems like a lot of them require Angular experience now. Having very little experience with it I'm not sure where to get started here. I have created the basic hello world angular + rails api app but I imagine they want a little more exposure than that. Can a more experienced rails dev tell me what kind of demo app / project I should work on to impress potential employers? I struggle with this sometimes too, I don't really have a great "creative" mind to break out of the usual sample apps when learning a new framework or language. If anyone else out there has input good things they do to come up decent side apps to work on I would be really interested. I tend to get stuck too much in creating solutions for my job which doesn't help since I can't open source it. For myself what I have been trying to do is find basic stuff in your life where you might thing a web app could potentially be useful. Even if its something that has been rehashed like a To-Do or note taking app its worth it to just get something out there that is completely your own, and has your own coding style. One interesting thing I found recently is a bunch of open APIs for random bits of city data (http://www.socrata.com/customer-spotlight/). It has stuff like 911 call data, lists of local parks, etc. Especially for JS MVC frameworks I have found this might prove somewhat helpful to act a data source you can just tie in to and build a simple single page app that will break away from the repeated example apps out there. MrDoDo fucked around with this message at 01:11 on Feb 4, 2014 |
# ? Feb 4, 2014 00:57 |
|
KoRMaK posted:Man, now I have a situation where a large portion of the response is the same for both js and html, but the last line differs. you could put the shared code above the response section? a separate function would be good too. Oh My Science posted:I have started looking for a junior rails dev position and it seems like a lot of them require Angular experience now. Having very little experience with it I'm not sure where to get started here. I have created the basic hello world angular + rails api app but I imagine they want a little more exposure than that. Can a more experienced rails dev tell me what kind of demo app / project I should work on to impress potential employers? I hate this. Requiring a front-end framework? These things are very easy to learn, I'd rather hire someone that can program that might not have experience with the framework and train them up than spend time looking for someone with just the right qualifications... kayakyakr fucked around with this message at 02:51 on Feb 4, 2014 |
# ? Feb 4, 2014 02:47 |
|
kayakyakr posted:
Welcome to the industry.
|
# ? Feb 4, 2014 02:54 |
|
The Milkman posted:Welcome to the industry. I can't wait for a year from now when people want Angular devs with 4+ years of experience.
|
# ? Feb 4, 2014 03:00 |
|
kayakyakr posted:I hate this. Requiring a front-end framework? These things are very easy to learn, I'd rather hire someone that can program that might not have experience with the framework and train them up than spend time looking for someone with just the right qualifications... Junior positions are few and far between in my city (specifically for rails) which is why they can be picky I guess. I have a really solid foundation in web development (everything from design to coding) and just want to be in a position where I can begin specializing in the area I like best. Oh well, I've met a few people at the local ruby meetup group, that may lead to something eventually.
|
# ? Feb 4, 2014 03:30 |
|
Just do a website with a three model relationship with jquery plugins, bootstrap, modals, ajax and angular.
|
# ? Feb 4, 2014 04:36 |
|
There is a libyaml CVE. If you're on heroku you can push an empty commit which will rebuild your app, and you'll be patched. If you're on something else, you'll need to update libyaml. There is no new ruby patchlevel or changes to ruby itself. You can see what version libyaml you have with ruby -ryaml -e 'p YAML.libyaml_version' You want [0, 1, 5]. Pardot fucked around with this message at 13:32 on Feb 4, 2014 |
# ? Feb 4, 2014 13:23 |
|
Ruby code:
Ruby code:
|
# ? Feb 4, 2014 14:48 |
|
I think this will be an easy one, but I'm confused on how to use module functionality in different places of the app. I have a Utils module in /lib/app_name_utils.rb. In several controller routines, I have logger = Utils::SingletonLogger.get_logger. Sometimes these assignments work, sometimes they don't. In particular, one tester tells me that roughly half the time he goes to one of the index pages, it crashes. I've been doing some Googling, and I know I could use code:
code:
I'm also not clear if I have to load/require the module everywhere I use it, or just in one central place (for now, I've added config.autoload_once_paths += %W(#{config.root}/lib) to application.rb). And I found a statement online that claimed that the name of the file in which the module resides should match the name of the module, which I haven't done. Is that critical? Peristalsis fucked around with this message at 19:49 on Feb 4, 2014 |
# ? Feb 4, 2014 19:46 |
|
Peristalsis posted:I think this will be an easy one, but I'm confused on how to use module functionality in different places of the app. Consider using the newly standardized concerns paradigm? http://richonrails.com/articles/rails-4-code-concerns-in-active-record-models
|
# ? Feb 4, 2014 20:17 |
|
kayakyakr posted:Consider using the newly standardized concerns paradigm? Alas, we aren't using Rails 4, and I don't want to restructure this code that was supposed to go out two months ago any more than necessary. Edit: Let me streamline my questions. 1) Is it enough for the application just to require/load the file somewhere before its modules are included, or does it have to be loaded in every file in which it is used? 2) Once loaded, does its module have to be included in every file where it will be used, or is there some global include list? 3) Is the name of the file relative to the name of the module important? 4) Is there a way to access the module's code without including it? (E.g., using ModuleName::MethodName seems to work some of the time in test, and all the time in DEV. I must have found that somewhere....) 5) If I do include the module in a file, can I still specify the module from which it came when I call it, or do I have to call it without a prefix or module specification of any sort? I'd like to keep the module name included when it's used just for clarity. Peristalsis fucked around with this message at 22:17 on Feb 4, 2014 |
# ? Feb 4, 2014 20:51 |
|
Peristalsis posted:Alas, we aren't using Rails 4, and I don't want to restructure this code that was supposed to go out two months ago any more than necessary. You should be able to require the file once and have it available, but you're probably safer to require it in every file that it's used. If you want it globally available, adding it to the autoload path is the way to go. Ruby code:
"include" and "extend" are modifying the class, adding the methods from the module onto the class that you're including them into. So yes, you have to include the module in every class that you want to have methods from the module. If your module doesn't have methods that you're adding to a class and you are just using it as a namespace, then you don't want to include it at all. While you could directly access module methods, I would suggest using a class with class methods instead, if you're going to do things that way.
|
# ? Feb 5, 2014 01:31 |
|
I am new-ish to Rails and web development in general and just managed to move my Rails app with PostgreSQL from Heroku to Digital Cloud using Dokku (which is basically meant to emulate Heroku). It was pretty challenging but all is working now. The one remaining thing I want to accomplish is to connect to my app's PostgreSQL server using pg Admin III on Windows. I have found some instructions that require a Linux tunnel but I don't think that would apply to me. Does anyone have any advice on how to do this? (P.S. When everything finally started to click with how Rails and jQuery play together I think I fell in love. I never thought I'd be able to make apps as cool as I have been able to do with what I have learned in just the past month.) vvvvvvvvvv Thanks! That worked. Buckhead fucked around with this message at 00:02 on Feb 11, 2014 |
# ? Feb 10, 2014 22:51 |
|
Buckhead posted:I am new-ish to Rails and web development in general and just managed to move my Rails app with PostgreSQL from Heroku to Digital Cloud using Dokku (which is basically meant to emulate Heroku). It was pretty challenging but all is working now. The one remaining thing I want to accomplish is to connect to my app's PostgreSQL server using pg Admin III on Windows. I have found some instructions that require a Linux tunnel but I don't think that would apply to me. Does anyone have any advice on how to do this? Shouldn't you just be able to open up the pg port on your server and connect to it that way (probably a really bad idea for security reasons)? Anyhow, you should be able to open an SSH tunnel on windows but I've never done it. Try using PuTTY. Here's their instructions for port forwarding: http://the.earth.li/~sgtatham/putty/0.63/htmldoc/Chapter3.html#using-port-forwarding What does windows do instead of SSH? I can't imagine functioning without it. DONT THREAD ON ME fucked around with this message at 23:30 on Feb 10, 2014 |
# ? Feb 10, 2014 23:26 |
|
I'm working on a thing where an admin can upload a series of images, and the front end will display one, then after X amount of time start displaying the next one. Alternatively it could complete a cycle every X (6-12ish) hours. It's not super strict in that regard. It's not a live loading JS thing, just on page load you'll get an image from the server. My first thought would be whenever/cron but perhaps there's a better way? Perhaps slicing up a chunk of time by the count of images and comparing it against the current time? I'd appreciate input from anyone who's tackled something like this before.
|
# ? Feb 10, 2014 23:54 |
|
The Milkman posted:I'm working on a thing where an admin can upload a series of images, and the front end will display one, then after X amount of time start displaying the next one. Alternatively it could complete a cycle every X (6-12ish) hours. It's not super strict in that regard. It's not a live loading JS thing, just on page load you'll get an image from the server. I'm not really understanding your question. Why can't you just use timeout? If you're not doing liveloading, you can just have an array of image URLs and every x minutes it pops a url off the array and displays it. Your method of comparing time would work but it would be needlessly complicated unless it would achieve some purpose that I'm not understanding.
|
# ? Feb 11, 2014 00:55 |
|
USSMICHELLEBACHMAN posted:I'm not really understanding your question. Why can't you just use timeout? If you're not doing liveloading, you can just have an array of image URLs and every x minutes it pops a url off the array and displays it. Because I didn't know about timeout Yeah I wasn't crazy about that idea, that's why I asked. Never had to deal with time in this sort of way before, especially in a web application and figured there had to be something better than what I cooked up on a monday with little sleep. Thanks! Edit: here's what I came up with this morning initializer: code:
code:
Chilled Milk fucked around with this message at 19:04 on Feb 11, 2014 |
# ? Feb 11, 2014 05:05 |
|
The Milkman posted:I'm working on a thing where an admin can upload a series of images, and the front end will display one, then after X amount of time start displaying the next one. Alternatively it could complete a cycle every X (6-12ish) hours. It's not super strict in that regard. It's not a live loading JS thing, just on page load you'll get an image from the server. Ruby code:
|
# ? Feb 11, 2014 20:53 |
|
I'd probably just create a sequence in my database, do something like (I forget the AR syntax, haven't been using Rails in a while)code:
|
# ? Feb 12, 2014 00:22 |
|
I have some code that repeats in all of my controller functions, so I'd like to move it to a module as a method. It uses "super" though, and this is where the thing falls apart. How do I pass the "super" method to be invoked by the helper function, or how do I run the edit_helper inline as a proc or something so that "super" makes sense?Ruby code:
|
# ? Feb 14, 2014 14:58 |
|
The problem with what you're trying to do is that in order for your module to call the superclass method :edit, your module method needs to be named :edit. If you do that, it will work fine. But the problem then is that you have a module method :edit, and a class method :edit, and they will conflict. Instead of calling calling the super method edit, can you rename the superclass method to something else and call it directly? or alias it? DONT THREAD ON ME fucked around with this message at 22:51 on Feb 14, 2014 |
# ? Feb 14, 2014 16:52 |
|
You could also do something like this:code:
DONT THREAD ON ME fucked around with this message at 23:37 on Feb 14, 2014 |
# ? Feb 14, 2014 23:34 |
|
That's a pretty terrible way to do it, especially performance-wise (MRI, for example, will invalidate all inline method caches when you alias an method). I'll post my thoughts tomorrow
|
# ? Feb 15, 2014 00:10 |
|
Smol posted:That's a pretty terrible way to do it, especially performance-wise (MRI, for example, will invalidate all inline method caches when you alias an method). I'll post my thoughts tomorrow Yeah I definitely wouldn't do it. I feel like the approach is bad in general, but I don't really have any counter suggestions. DONT THREAD ON ME fucked around with this message at 08:37 on Feb 15, 2014 |
# ? Feb 15, 2014 02:43 |
|
KoRMaK posted:I have some code that repeats in all of my controller functions, so I'd like to move it to a module as a method. It uses "super" though, and this is where the thing falls apart. How do I pass the "super" method to be invoked by the helper function, or how do I run the edit_helper inline as a proc or something so that "super" makes sense? Be less vague: what's the end goal here? What does the repeating code actually do?
|
# ? Feb 15, 2014 20:00 |
|
I'm having a brainfart working on this Rails migration. I'm trying to model an attribute that can have three possible values: "Yes", "No", and "Yes, but..". What type should I be using for this? A string with a validation to ensure that the value is one of those three things?
|
# ? Feb 16, 2014 02:51 |
|
An integer? Does the attribute really need to be persisted? i.e. can the state be derived from other attributes on the model?
|
# ? Feb 16, 2014 04:15 |
|
Sounds like an enum! Rails 4.1.0, which is at beta3 status, includes ActiveRecord::Enum in core. Or if you don't feel like living ON THE EDGE there are a few gems that'll do basically the same thing. simple_enum is one I've used.
|
# ? Feb 16, 2014 04:29 |
aunt jemima posted:Sounds like an enum! Rails 4.1.0, which is at beta3 status, includes ActiveRecord::Enum in core. Never use someone's random gem for stuff like that. You're really just asking for a headache down the line when it's no longer supported because the developer abandoned it. You'd be better off using a simple integer or string value if it's literally only a yes/no/maybe situation if being on an edge version of Rails isn't a possibility. Don't over-engineer a solution that doesn't need to be.
|
|
# ? Feb 16, 2014 05:03 |
|
Or switch to MongoDB
|
# ? Feb 16, 2014 05:08 |
|
double sulk posted:Never use someone's random gem for stuff like that. You're really just asking for a headache down the line when it's no longer supported because the developer abandoned it. You'd be better off using a simple integer or string value if it's literally only a yes/no/maybe situation if being on an edge version of Rails isn't a possibility. Don't over-engineer a solution that doesn't need to be. This is extremely practical advice, given the situation. Don't change your Rails version or database technology for a single field type.
|
# ? Feb 16, 2014 05:49 |
|
double sulk posted:Never use someone's random gem for stuff like that. You're really just asking for a headache down the line when it's no longer supported because the developer abandoned it. You'd be better off using a simple integer or string value if it's literally only a yes/no/maybe situation if being on an edge version of Rails isn't a possibility. Don't over-engineer a solution that doesn't need to be. Or a boolean where true = yes, false = no, and null = maybe
|
# ? Feb 16, 2014 06:25 |
|
Using null to mean something other than null would probably have a lot of unintended consequences. Plus you wouldn't be able to tell whether the field was truly null or 'maybe.' Just use 1,0,-1. Integers are cheap, and the only part of your domain that needs to have any idea that your db is storing integers and not something meaningful like true/false/maybe are the methods you use to store and access the data. Once you've pulled it from the DB, you can give it a meaningful representation.
|
# ? Feb 16, 2014 07:13 |
|
USSMICHELLEBACHMAN posted:Or switch to MongoDB Then you're demanding a headache down the line.
|
# ? Feb 16, 2014 07:22 |
|
woops
|
# ? Feb 16, 2014 07:25 |
|
Using null in a boolean to mean anything more than an absence of a value is a bad practice. Nothing wrong with a string that only allows three values, you can define the values as a constant in the model. This lets you throw the validations down on the constant, populate the form select/radio with the same values, base your tests on them, etc. You probably don't need to go all out and treat the attribute as a state, but you could always upgrade the string attribute to a state if your logic demands it.
|
# ? Feb 16, 2014 07:31 |
|
USSMICHELLEBACHMAN posted:Using null to mean something other than null would probably have a lot of unintended consequences. Plus you wouldn't be able to tell whether the field was truly null or 'maybe.' Just use 1,0,-1. Integers are cheap, and the only part of your domain that needs to have any idea that your db is storing integers and not something meaningful like true/false/maybe are the methods you use to store and access the data. Once you've pulled it from the DB, you can give it a meaningful representation. Unless the absence of value is the default state meaning yes and no haven't been set yet. He was pretty light on details, but if there can only be 3 states (yes, no, unset) then a nullable boolean is fine. If there are actually 4 states (yes, no, maybe, unset) then yes, an integer or string is more appropriate.
|
# ? Feb 16, 2014 16:22 |
|
|
# ? Jun 3, 2024 22:25 |
|
aunt jemima posted:Sounds like an enum! Rails 4.1.0, which is at beta3 status, includes ActiveRecord::Enum in core. This is pretty cool. Is there a page that lists a summary of new features in Rails 4.1.0? Also, does anyone have a recommendation for a logging plugin? I'm looking for something that will send a daily summary of any 500 errors with the relevant log output included.
|
# ? Feb 16, 2014 19:59 |