|
a
DONT THREAD ON ME fucked around with this message at 03:17 on Oct 8, 2014 |
# ¿ Jan 17, 2013 13:40 |
|
|
# ¿ Apr 27, 2024 11:28 |
|
a
DONT THREAD ON ME fucked around with this message at 03:17 on Oct 8, 2014 |
# ¿ Jan 18, 2013 10:49 |
|
Warning: This ended up being a really stupid problem. Okay, I'm confused. I have a 3 model hierarchy, Series -> Seasons -> Episodes. code:
I've spent the day messing around with my controllers and routes (I nested the route on these 3 models, just to get an idea of how it works). I'm struggling a bit with rerouting everything, but that's fine. What I'm really confused about is that now, I can no longer create new seasons. They tell me I need to define a series_id. code:
(I believe the Season Exists error is because the season_id is nil, not because the season_number exists). Of course, I can't mass assigned the series_id, (and I don't want to). I've changed absolutely nothing on the models, aside from adding the default_scope order to Episodes. As I said, I've changed a lot with my controllers and routes, but none of that should apply to direct calls from within the console, right? What am I missing? edit: I figured it out. I had a helper function in my Series model, code:
code:
DONT THREAD ON ME fucked around with this message at 04:23 on Jan 21, 2013 |
# ¿ Jan 21, 2013 03:43 |
|
Two somewhat related questions: So the @ symbol means a var is scoped within a model/object, correct? So this means that using @ in a controller doesn't really do anything? Second: It seems like the same scoping applies to helpers. How to helpers work exactly and what is the best practice with them? I realize you have to require them by your controllers in order to make use of them -- does that mean it's generally bad practice to use a helper within a controller? I'm just really confused about what should be in a helper and what should be in a model. I've always read "skinny controllers, fat models," but in the tutorial I went through, the practice seemed to be "skinny controllers, skinny models, fat helpers."
|
# ¿ Jan 24, 2013 07:03 |
|
I'm trying to get chunked/resumed uploads working with the jquery uploader (https://github.com/blueimp/jQuery-File-Upload). I seem to remember reading somewhere that rails isn't really optimal for dealing with bitrange html headers (or something) and that I should use Apache for the file serving aspect. Is this true?
|
# ¿ Feb 2, 2013 21:16 |
|
Alright, I"m launching my first production rails application on monday, I want to make sure I have my security ducks in a line, here: w/r/t: https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/AFBKNY7VSH8, I'm running Running rails 3.2.12, all of my models use attr_accessible w/r/t: https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/RieVvnRGq8s I"m running JSON 1.7.7 w/r/t the YAML thing, as I said, I'm using rails 3.2.12 Am I missing anything? Is there anything else I should be aware of?
|
# ¿ Mar 1, 2013 20:44 |
|
Smol posted:Here's a few security-related tools that are useful for every Rails' developer. We run brakeman on our CI, it's very easy to set it up with Jenkins. Also be sure to subsribe to the rubyonrails-security Google group. Bundler audit is nice. Thanks! quote:Have a backup strategy for when you get attacked by an rear end in a top hat and a page at /security with a PGP public key and an address for when you get attacked by a non-rear end in a top hat.
|
# ¿ Mar 1, 2013 23:22 |
|
Probably because the post is an hour old and audit isn't aware of it yet
|
# ¿ Mar 18, 2013 19:24 |
|
Lexicon posted:I should've read more before posting. Turns out a feature of it is that it doesn't require a network connection, and has its own dataset of vulnerabilities that gets updated periodically. So presumably you only ever get notified if you bundle update it, and then run it? Hmph. wow, I also assumed it was querying a server somewhere. It would make sense that it takes at least an hour or two to get updates. That kinda sucks, but I don't think it's really intended as an up to the minute security watchdog; it's more more of a thing to use before an initial rollout/after major updates.
|
# ¿ Mar 18, 2013 19:32 |
|
Lexicon posted:Yeah :/ Fair enough - still a useful thing, but I guess it's not quite what I thought it was. Yeah it would just need to be an RSS feed setup somewhere with a vulnerability list. Anyhow, it's not going to tell you anything that the google group doesn't, so your best bet is to just subscribe to that.
|
# ¿ Mar 18, 2013 19:38 |
|
Cocoa Crispies posted:It's not "ror" unless you're a recruiter, it's "Rails." Objects only usually have one file. Just because the scaffold generator makes files with similar names doesn't mean they have to be related. For me, it's definitely the largest minor annoyance in working with rails, and it's a totally legitimate thing to ask about. Rails' file structure, while logical, is pretty frustrating to navigate. Usually by the time I scroll through my views, I've forgotten what I'm looking for. quote:Just because the scaffold generator makes files with similar names doesn't mean they have to be related. This is absurd.I didn't use the scaffold generator when I was starting out, but I still gave things similar names and put them in similar folders and obeyed the MVC, because it literally wouldn't work otherwise. Rails is built around the MVC and it places a huge emphasis on convention. If you give your controllers and models different names, you're going to make things hard on yourself. If you put files in the wrong folder, you're going to make it hard on yourself. Just because you can get around the convention, that doesn't you don't "get" ror unless you put everything in non standard locations. It's called Ruby on Rails for chrissake. That said, I don't have an answer to the question. I tried creating a folder of symlinks outside my rails directory, and those folders grouped related models/controllers/views. But it was too much of a hassle to deal with.
|
# ¿ Jun 13, 2013 22:49 |
|
Does anyone have any examples of really well written/designed gems (ruby or rails specific)? I'd like to put a really solid piece of code up on github as a work example, and I want to make sure I'm following solid design patterns.
|
# ¿ Jul 18, 2013 20:42 |
|
Safe and Secure! posted:Is there anything I can do, or any reason for me, to try prevent users from entering dangerous stuff as, say, usernames and email addresses in my Rails 4 app? I know there's a sanitize helper for the views, and I guess I could just run input through that before creating a model, but I'm interested in validations for this. Yeah you should sanitize in your view and in your model. In your model you should be doing validations on any model before it's created. http://ruby.railstutorial.org/chapters/modeling-users#sec-format_validation
|
# ¿ Jul 22, 2013 07:15 |
|
Safe and Secure! posted:I need to style the markup of my Rails app's views. Can this just be as simple as looking at the bootstrap documentation and then making sure that all my HTML elements have classes from bootstrap, or is there anything I should keep in mind as go through it? I'm using the bootstrap-sass and sass-rails gems, if that changes anything. It certainly can be that simple -- if you use bootstrap you dont have to ever touch a css file. Your views will look good but they will also look pretty generic as bootstrap is becoming fairly ubiquitous. The bootstrap website has a thing that will let you customize the style and then import it into your project, so you can try that. I didn't find it very useful. If you need something more bespoke, you'll need to get into writing custom css files and using bootstrap mostly as a helper. But if you're starting out, I dont think there's any harm in just bootstrapping everything and then tweaking it from there.
|
# ¿ Aug 16, 2013 07:53 |
|
rspec and capybara will do the job if you're just getting started. Spork will greatly speed up test startup and run time. If you use any Ajax/js, definitely consider disabling transactional fixtures and installing the database_cleaner gem. It will save you a lot of headache. FactoryGirl is really really awesome, I like it so much I started using it in development.
|
# ¿ Aug 16, 2013 18:04 |
|
I really need to give cucumber a shot. The regex thing really turns me off, (not because I cant write regexes), it just seems like such an odd way of going about things. And if you're not really consistent with your syntax I expect it's super confusing to write. Is cucumber particularly well suited to anything, like view testing or integration testing? DONT THREAD ON ME fucked around with this message at 20:05 on Aug 19, 2013 |
# ¿ Aug 19, 2013 19:45 |
|
Cocoa Crispies posted:It's very very high level integration testing: I use it as a to-do list that checks itself off. I've heard that you should write scenarios in a way that you could use the same set of scenarios for HTML, iOS, and Android versions of an application. Okay that makes sense to me. This is kind of how I think of view testing (which I guess implicitly is integration testing), and I really hate doing it in Rspec/Capybara, so I'll give it a shot.
|
# ¿ Aug 20, 2013 00:08 |
|
I messed with cucumber pretty hard last night and I take back all of the bad things I ever said.
|
# ¿ Aug 20, 2013 16:49 |
|
Tru cucumber. I'm on day 3 of migrating all my integration tests from rspec to cucumber and it's awesome. It sounds awful in theory but it's awesome in practice. Keeping bloat down feels really natural compared to rspec. DONT THREAD ON ME fucked around with this message at 18:16 on Aug 22, 2013 |
# ¿ Aug 22, 2013 18:08 |
|
prom candy posted:Would you be willing to share a before/after of one of your tests? I'm thinking of adding Cucumber into a site that I've been managing for a few years. Our business-end client is exactly the kind of guy who can read and understand natural language features so I'm thinking it could be a good fit, but every time I sit down to write cucumber tests I feel like I'm wasting my time programming to a crazy DSL rather than just telling it what I want to test. Yeah let me find some less embarrassing code. I'm pretty new to testing so my before/afters might not be a great example, but maybe you guys can give me some pointers. Question: I had a bug in my application that was causing the DB to lock up when a form got double posted. I switched to postgres and fixed some issues, but I've never actually managed to replicate the bug. The post is submitted via JSON, and I've tried just sending multiple JSON posts but it wont happen. I've also tried manually clicking the button really fast but that doesn't do it either. Still though, users are managing to pull it off. Any tips?
|
# ¿ Aug 23, 2013 18:01 |
|
Yeah I was using SQLite, and now I'm using postgres, so the problem is fixed. I just want to know how to test for the error, because I can't replicate it (on a server using an SQLite db).
|
# ¿ Aug 23, 2013 19:37 |
|
Wow ajax/javascript integration testing is extremely frustrating. I pretty much only have one model with more than a trivial amount of ajax/javascript, and both selenium-chrome, selenium-firefox, and capybara-webkit all have different problems, unrelated problems that don't exist on a real browser. It's not even async problems, I've got those mostly worked out. It's things like the browser trying to click on buttons off screen (and failing), or z-index issues making buttons unclickable. DONT THREAD ON ME fucked around with this message at 05:57 on Sep 9, 2013 |
# ¿ Sep 9, 2013 05:54 |
|
This is how I deal with problems like that. It's not very "rails" but my code got way, way cleaner when I stopped using callbacks that do anything more than change the internal state of the model. I've never used :accepts_nested_attributes though so I don't know much about it. http://samuelmullen.com/2013/05/the-problem-with-rails-callbacks/
|
# ¿ Sep 9, 2013 07:13 |
|
Cocoa Crispies posted:Is the JS modular and DOM-independent enough that you can use something like jasmine to unit test it? Unfortunately no. Most of my JS comes from gems or is so simple that it doesn't really need to be tested, I'm really only testing the JS elements implicitly. It's just that (one of my more important) views has a lot of ajax going on and I can't test it unless I'm in a JS capable webdriver.
|
# ¿ Sep 9, 2013 19:49 |
|
rails tutorial is good and will teach you a lot of other useful skills (git, if you dont know it already) and probably taught half the people in this thread
|
# ¿ Sep 24, 2013 00:03 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
Or switch to MongoDB
|
# ¿ Feb 16, 2014 05:08 |
|
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 |
|
woops
|
# ¿ Feb 16, 2014 07:25 |
|
I've been applying for ruby on rails jobs a lot lately, and the big thing that seems to be holding me back is that I don't have any experience dealing with applications "at scale." I'm running a "mission critical" rails app at my job, but it's mostly an internal app and it doesn't see a ton of traffic. The "do you have experience scaling rails apps" question keeps coming up on interviews, and I don't have a good answer for it. Our app is deployed on aws and I have experience with that side of things, but I haven't dealt with load balancing and I coulnd't sync databases between CDNs. How can I go about building some skill/knowledge in these areas without actually running a high traffic web application? Or should I not worry too much about this stuff if I'm just seeking a job as a junior developer?
|
# ¿ Feb 21, 2014 21:33 |
|
Pollyanna posted:Okay, so two out of two interviews so far have touched on whether I was familiar with Rails. I am not, and I haven't done anything with Ruby past the tryruby tutorial months back, so I'm going to go ahead and just learn it already. Is the Rails tutorial a good place to start, or should I start with something more about Ruby in general? Yeah it's the place to start. You don't need to start with Ruby. I'd start with Rails and then jump more deeply into Ruby later. But he even includes a more in depth look at ruby in section 3 or 4 or something. Alternatively you could just run through the codeacademy thing on ruby, that will get you up to speed in a few hours. Also don't listen to those guys who told you not to bother with the testing stuff -- they might not care about it but almost everyone else will.
|
# ¿ Feb 21, 2014 22:08 |
|
kayakyakr posted:This is actually good advice. develop a good testing habit so that you don't develop a bad no-testing habit like I did. It's hard to break. Thanks, I'll at least learn how to talk about this stuff. I guess I'm frustrated because I've gotten the 'I guess we were looking for someone a bit more senior' line a few times now and really the only Rails thing I'm definitely inexperienced with is operating at scale. (But it could just be that I've said dumb things during interviews. Or that I'm applying at places that don't know what they want). I've asked a bit in the jobs thread, but I'll ask here: Aside from applying to everything on linked in, any leads for tracking down junior level rails positions? I've got about 2 years under my belt but like I said, it wasn't at any kind of scale. I feel like I should be a shoe-in for a jr position but I havent had a lot of luck yet.
|
# ¿ Feb 22, 2014 02:05 |
|
Hello friends, I work on a very large, old (for rails) codebase. My team has inherited a large section of code and none of us really understand it. Anyhow, I'm trying to write some tests using the existing factories, and they're a mess. I don't want to use them, but they need to remain in place because we have tons and tons of other tests currently relying on them. What is the best way to work around the existing factories without removing them? My options: 1) Settle for doing something like FactoryGirl.define(:class_new, class: class) with all my new factories 2) Refactor all the old factories/tests to use FactoryGirl.define(:class_old, class: class) Or something like: code:
4) Use FactoryGirl.modify to modify the classes as needed. I think this would just create more confusion. 5) Just live with what's there. 6) Don't use factory girl. Which of these is the least idiotic? I'm leaning towards number 2. DONT THREAD ON ME fucked around with this message at 00:31 on Jul 31, 2014 |
# ¿ Jul 31, 2014 00:29 |
|
|
# ¿ Apr 27, 2024 11:28 |
|
kayakyakr posted:e: option #7 and the one that will probably cause you the least heart-ache long run is refactor the factories through the complete code base. In other words, fix the factories and then fix broken tests. Yeah, that's the very long term goal. Ideally someday we'll move the tests over to using the new factories but who knows if that will ever happen. At least new tests will have maintainable factories to use.
|
# ¿ Jul 31, 2014 01:59 |