|
The app I'm working on has somehow gotten itself into a bizarre state. I created a migration to get rid of two now defunct columns:Ruby code:
code:
code:
It's almost as if rake is using a weird cached version of the model, and not the actual one. Any thoughts?
|
# ¿ Oct 16, 2012 16:53 |
|
|
# ¿ Apr 27, 2024 09:26 |
|
The Journey Fraternity posted:If you're dropping the entire database to reseed it, why not just load the database from schema? Yeah, fair point. I'm new to this team, and that's what they all do as a matter of course. Anyway, a guy on our team found the solution to this: FactoryGirl needs to be reloaded: Ruby code:
|
# ¿ Oct 16, 2012 17:39 |
|
^^ Is MySql workbench really that bad? I've never used it, but assumed it was the de facto standard tool.
|
# ¿ Oct 18, 2012 03:36 |
|
Lexicon posted:^^ Is MySql workbench really that bad? I've never used it, but assumed it was the de facto standard tool. I've just inherited a rails app and for some reason the browser history is totally broken. You can navigate around the site just fine, but the URL in the URL bar never changes to anything other than the site root. I'm not really a javascript guy, but I'm assuming there's some javascript fuckery going on here. Can anyone point me in the right direction for sorting this out?
|
# ¿ Oct 18, 2012 14:20 |
|
I want to build a dashboard type thing in rails that will run some SQL queries on a database (not the rails persistence database - a business database elsewhere that already exists), and then display charts of the results in the web UI. Any recommendations for a technique to do this? I was thinking of using google's chart API.
|
# ¿ Oct 30, 2012 04:25 |
|
A MIRACLE posted:Active Admin + your favorite SVG based javascript graphics library. Is Active Admin a good way to run arbitrary SQL on an unrelated database though?
|
# ¿ Oct 30, 2012 14:23 |
|
Following on from my above question, I've found a way to use ActiveRecord infrastructure to make connections to a non-rails database:code:
|
# ¿ Oct 30, 2012 21:02 |
|
I'm building a rails app which will be hosted on Heroku and pulls data from an RDS MySql connection. Note that this connection is in addition to the Postgres connection to the database that's the persistence layer for the rails app itself. I've been able to authorize Heroku to connect to the RDS instance; however, it replaces CONFIG['DATABASE_URL'] with the mysql connection string, which is not a huge problem in itself. The thing is, the value stored there is a Mysql2 connection string: e.g. mysql2://user:pass@.... I want to use the mysql2 gem to connect to this database, and Mysql2::Client.new takes a hash of parameters. Short of doing a regex to pull out these parameters into a hash, is there a way to connect using a connection string?
|
# ¿ Nov 7, 2012 22:17 |
|
Pardot posted:You can use the URI stdlib Worked perfectly. Thanks!
|
# ¿ Nov 8, 2012 18:09 |
|
Has anyone here tried to pull data from the google analytics API from within a rails app? It seems like an utter clusterfuck with a bunch of defunct gems to interface with it, and Google's own ruby library in alpha. I can't find half decent sample code anywhere on the web
|
# ¿ Nov 15, 2012 00:35 |
|
kitten smoothie posted: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? Seriously, this.
|
# ¿ Nov 16, 2012 04:05 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
DankTamagachi posted:Thank you all for the help here! I noticed this morning the same thing you did- simple math meant that if I was to_i'ing to INTs all the time, the rating bottomed out at 1 pretty quickly. D'oh! Golden rule of MVC is: Fat models, thin controllers.
|
# ¿ Nov 25, 2012 20:21 |
|
Not sure if this is the best place for this question, but here goes: I recently jumped ship from MacVim to Sublime Text 2, as the vintage (i.e. vim) mode is now close enough to vim for me, and it's a much nicer editor as a whole. One complaint: the javascript syntax highlighting isn't quite up to par - for example, javascript dicts don't have the keys displayed in a different color the way they do in MacVim with Janus. Is there a way to fix this?
|
# ¿ Nov 26, 2012 19:02 |
|
^ Ok will do, thanks.
|
# ¿ Nov 26, 2012 20:12 |
|
Smol posted:There is no need to make it more complicated than it has to be. For loop also reads better and is easier to type. #each is the right tool when you want to do a side-effect after a series of transformations. Your entitled to your opinion, but you are at odds with virtually the entire ruby community. each {} is the standard way to iterate over a collection, and for-loops look downright bizarre in ruby code. I've never even written one.
|
# ¿ Dec 13, 2012 18:16 |
|
Lexicon posted:Your entitled to your opinion, but you are at odds with virtually the entire ruby community. each {} is the standard way to iterate over a collection, and for-loops look downright bizarre in ruby code. I've never even written one. Ok, I have far less conviction in this statement if DHH is a for-loop guy...
|
# ¿ Dec 13, 2012 19:41 |
|
What's preferable? a = Hash.new or a = {} I'm a python refugee and am biased towards the latter, but I see both. Is there a majority opinion on this?
|
# ¿ Dec 24, 2012 02:28 |
|
Smol posted:The latter. Only use Hash.new when you need to use one of the special constructors for providing default values or something similar. Great, thanks. Every time I create one, I wonder which to use. This finally can be put to rest.
|
# ¿ Dec 24, 2012 04:39 |
|
Daynab posted:Hi, I'm interested in learning Ruby and then RoR but I had a question and there's no general Ruby thread - how useful is plain standalone Ruby to code programs compared to say... Python? Is it versatile or is it more "the language that Rails just happens to run on"? As a data point, I used Ruby extensively for scripting, parsing, automation etc long before I ever got into rails.
|
# ¿ Dec 24, 2012 18:17 |
|
This should be super easy, but I can't quite work it out: I want to create a simple form in rails that's not coupled to an ActiveRecord model. I simply want to hit a controller, and then I'll deal with the posted params from there. However, when I click my button, nothing happens - my controller never gets hit. The route is properly set up.Ruby code:
|
# ¿ Jan 15, 2013 00:47 |
|
Physical posted:Is it the difference between button and submit_tag? Or is your form tag crossing any div tags? Just tried submit_tag - same result. And I'm not sure what you mean by the latter point. The HAML is well formed, I'm pretty sure.
|
# ¿ Jan 15, 2013 02:58 |
|
I've been using Sublime Text 2 for rails for a few weeks, and generally love it. However, after rebooting my machine today, its ruby linter is acting up. It is complaining about things like this:Ruby code:
Any idea what the hell is going on?
|
# ¿ Jan 22, 2013 20:02 |
|
Civil Twilight posted:The linter is checking your code with ruby 1.8 (probably the default system ruby), which doesn't have that hash syntax. Make sure you're getting the right version of ruby at the command line, and you might need to configure SublimeLinter to use a specific ruby instead of the default. Yeah, that makes sense, however: code:
code:
|
# ¿ Jan 22, 2013 20:30 |
|
Dangerllama posted:This sounds like teaching Linear Algebra before someone's taken Algebra I and II. No kidding. Pardot - do yourself a favour and put Rails aside until you're comfortable with Ruby and universal programming constructs such as looping, objects, etc. I'm an experienced software engineer and I find Rails to be a big beast to handle at times.
|
# ¿ Jan 28, 2013 04:11 |
|
enki42 posted:I find starting 100% with Ruby just gets people frustrated that they're not actually making something useful. Plus if you're just going with pure Ruby, people won't be motivated to experiment with stuff outside of direct exercises you give them. Devil's advocate: Why not base a course off something like projecteuler.net (or equivalent - adjust for your audience's interests)? I find that people are surprisingly intrigued to find out that programming opens up a whole world of problem solving that was previously inaccessible.
|
# ¿ Jan 28, 2013 04:14 |
|
Can someone explain or point me towards an overview of the threading model in rails? I'm curious in particular about the performance implications of server side network requests or file reads, etc.
|
# ¿ Jan 30, 2013 17:58 |
|
Smol posted:Short answer: don't do it, unless you're on JRuby. And even then, it depends. What version of Rails are you running? 3.2.11 How would one handle an image proxy, say, in a rails app if server side requests are not a good idea?
|
# ¿ Jan 30, 2013 20:50 |
|
This guy paints a particularly dire picture of the Rails security situation right now: http://www.kalzumeus.com/2013/01/31/what-the-rails-security-issue-means-for-your-startup/ How much of this is bluster and how much should be taken seriously? Is Rails really that much worse than other environments, e.g. PHP?
|
# ¿ Feb 3, 2013 17:09 |
|
Thanks; that's a very well-reasoned and rational point of view. I've only been involved in rails in earnest for about 4 months - I love it unreservedly, and want to use it for some future project ideas, but this recent security flap has given me some pause.
|
# ¿ Feb 3, 2013 18:53 |
|
Smol posted:Also, remember how much Rails does by default to protect you. Do you know what an IP spoofing attack is? Or how to use cryptographic signatures in a way that does not expose you to timing attacks? What characters do you need to escape to prevent XSS vulnerabilities? Exactly. Very true. Today I was wondering: is the dynamic nature of ruby something that necessarily poses risks within rails (or python and django) that wouldn't occur in a statically typed language? Java, for example, is truly horrendous to work with, but I imagine its a lot harder to actually inject malicious code. Am I off base here?
|
# ¿ Feb 4, 2013 05:44 |
|
Another security question: I'm working on an app where users are asked to enter a zip code, and this is posted to a rails route, and eventually entered into the Submission.zipcode model attribute in the database. It goes without saying that I'll be checking for valid zipcode-ness on the client side. What about on the server side, as someone could construct a malicious post if they were so inclined. I assume ActiveRecord has some degree of SQL injection protection, but what's the best practice here? It's easy to use model validation in the case of a zip code, but what about an arbitrary text field? Phrased differently, what's an appropriate level of paranoia?
|
# ¿ Feb 6, 2013 04:02 |
|
dexter posted:ActiveRecord will handle escaping the data for you along with validating that it is a string unless you do something stupid like Model.executes("INSERT INTO `table.... It's up to you to enforce further constraints on the data that it's actually a valid ZIP code. Thanks... That confirms everything I thought. Just wanted to be sure I wasn't missing something important.
|
# ¿ Feb 6, 2013 05:00 |
|
prom candy posted:Update Rack if you're using it, more security fun: http://rack.github.com/ What exactly is rack? I've read the overview page on github and I'm not really any the wiser.
|
# ¿ Feb 8, 2013 22:51 |
|
|
# ¿ Apr 27, 2024 09:26 |
|
Smol posted:Dynamically typed frontend and a weakly typed db is a recipe for trouble. Why does weak typing exist, like, at all? It seems to do nothing but cause huge headaches, often of the security variety.
|
# ¿ Feb 13, 2013 02:11 |