TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

How I Learned Enough Ruby On Rails In 12 Weeks To Launch Freelancify

184 点作者 james-fend超过 13 年前

17 条评论

tptacek超过 13 年前
Congrats on the launch. I think I speak for everyone on HN when I say, you're going about this the right way: learn enough to build applications for yourself, whether or not you're going to be a code committer over the long term.<p>Can I give you some quick advice? Don't take this the wrong way: Rails makes it easy to learn enough to be dangerous in 12 weeks. Some quick hits on obvious things you should look over in your application to ensure it isn't overtly insecure:<p>* Every model class should have an "attr_accessible" statement, and the attributes you expose through it should be minimal. A very common misconception: "the things in attr_accessible are the only attributes users can set". Not so! The things in attr_accessible are the only attributes users can set <i>automatically, through mass assignment</i>. You can expose things that aren't in attr_accessible by manually settings them with assignment statements. Assume anything that's in an "attr_accessible" list, and <i>every</i> attribute of a model without attr_accessible, can and will be set to the most hostile possible value, like "role=admin".<p>* Rails programming intros have a bad habit of introducing ActiveRecord finders in the context of the model class object --- in other words, "Post.find(params[:id])". This is exactly the wrong way to do it; it's so bad that you can literally generate a list of vulnerabilities on Rails projects by grepping app/controllers for "[A-Z][a-z]+]\.find". Instead, make sure all your finders work via associations, like "@current_user.posts.find(params[:id])".<p>* Use a popular plugin for file uploads. Rails doesn't do much of anything to defend against file upload/download vulnerabilities. If I was building a public-facing Rails application, I'd do whatever I could to keep the filesystem namespace out of my requests --- storing all files on Amazon S3 without explicitly storing them in temp files is a good way to do this.<p>* Don't enable the old-style wildcard route ("/:controller/:action/:id) or any of its variants ("/posts/:action/:id :controller =&#62; :posts); whether you declare methods "public" or "private" in a controller should have nothing to do with whether they're exposed to attackers.<p>* Have a "PreauthController" that inherits from "ApplicationController" and <i>disables</i> the is-logged-in check; in other words, every controller, particularly every controller generated by "rails generate", should be post-authentication <i>by default</i>. Set up the before_filter that checks for a valid user session right there in ApplicationController, then "turn it off" for the LoginController by having it inherit from PreauthController. Similarly: if you can get away with not having an AdminController at all --- run a totally separate Rails app for admin that requires a VPN to get to --- do that; otherwise, have an abstract AdminOnlyController class with no methods in it that does nothing but set up a before_filter to check for admin privileges, and have every admin-only controller inherit from it.<p>* Pretend the backtic operator (the one that executes Unix commands) doesn't exist.<p>You may do all of these things already (in which case, good for you! you learned more in 12 weeks than a lot of Rails developers do in years). I just called them out because (a) not doing them will be tremendously painful down the road (individual XSS slipups are annoying but unlikely to kill you, but vulnerabilities that allow people to dump your whole database are something else) and (b) they are so easy to fix.<p>Good luck!
评论 #3520159 未加载
评论 #3520154 未加载
评论 #3520440 未加载
评论 #3519940 未加载
评论 #3519734 未加载
saltcod超过 13 年前
The other thing I want to add is how much 'else' I learned while running through Michael Hartl's tutorial.<p>Despite many years making websites, I really had no clue about basic http methods — get, put, post, etc — and in fact, I didn't even realize what they were. The other huge, huge thing for me was finally figuring out what REST is all about.<p>Basically, the web runs on those few basic http methods, and using the REST approach spells that out for you and cements it in your head.<p>I had an awesome jump-up-and-down moment when it finally clicked.
评论 #3519932 未加载
评论 #3518585 未加载
freehunter超过 13 年前
I get really annoyed when there is an element that follows me down the page as I scroll. It's really distracting. I get even more annoyed when I have to set up an adblock rule to make it go away.<p>Please, designers, stop doing this (and stop doing menu bars with the same behavior). There's not much on your site that is important enough that I need it to follow me everywhere.
saltcod超过 13 年前
Fantastic post. Thanks so much for it. I decided to really dig into Ruby on Rails after Christmas this year, after thinking/talking about it for years. I was thrilled to hear that you really had no programming background—I think a lot of us are in this boat.<p>I watched the Lynda.com videos on Ruby, and the one on Ruby on Rails (both from Kevin Skoglund). I just watched enough of both to get fairly overwhelmed and confused, then moved on to Michael Hartl's site. Things started to click much better there—that's the best Rails resource I've seen to date.<p>Still though, After really digging in over the evenings and two weekends, that nagging feeling started to set in—am I actually going to 'get' this? Am I wasting my time? Is this going to take years? Will I ever get past layouts/partials? Should I just go learn PHP / Javascript / iOS / something else?<p>Did you feel like giving up? Or question the purpose/wisdom of learning Ruby and Rails?
评论 #3520166 未加载
评论 #3518293 未加载
评论 #3519225 未加载
tmh88j超过 13 年前
Great write up. I experienced a similar adventure in learning PHP over the past couple months and I completely agree that the first few weeks are by far the hardest.<p>Late last summer a friend and I came up with a great idea but we lacked the programming skills to create it ourselves. I knew a bit of HTML, a touch of c++ , and PLC ladder logic programming(huge help, right?). It wasn't until around October that I realized we were getting nowhere. I decided enough was enough and I was going to learn how to program. I spent an entire weekend reading and trying out zend's PHP 101 for beginners. Three months later and I had created a user authentication system with messaging, friends lists, administrative rights, and all sorts of other goodies. I was working a full time job so I did this with my spare time.<p>Your site looks great by the way. Keep up the good work.
评论 #3518181 未加载
jwong42超过 13 年前
Hey James, very inspiring read. I've been following your story and progress on the fastlane forum and glad to see that you had a successful launch! I've also been learning to program myself but my language of choice was python and django for framework. You are right that it takes some time to get through that initial learning curve but once you reach that first stage and figure out how to get past everytime you get stuck, it gets pretty exciting and fun. Congrats and best of luck to you!!
GnomeChomsky超过 13 年前
Any advice for getting started for someone without a Mac? I remember once trying to learn and immediately stalling out during setup (lame, I know). I have WinXP &#38; Ubuntu, and would like to take a stab at this again no matter how stupid I feel about not even being to able to install the damn stuff to start with.
评论 #3518430 未加载
评论 #3518400 未加载
评论 #3519348 未加载
评论 #3518416 未加载
评论 #3518438 未加载
评论 #3519263 未加载
评论 #3521829 未加载
评论 #3518453 未加载
civild超过 13 年前
I just had a look at Freelancify and registered, and I'm amazed that you did it all in 12 weeks learning Ruby from scratch. Kudos!<p>Based on your experience, how do you think learning materials/tutorials could be improved for people learning from scratch?
评论 #3518669 未加载
评论 #3518263 未加载
spiredigital超过 13 年前
Awesome work, James!<p>Your site looks really nice, and now you've got the ability to do design AND program, which is a combo that isn't too common.<p>Best of luck with your site....
evanlong超过 13 年前
XSRF: <a href="https://github.com/evanlong/security/blob/master/web/csrf/freelancify.html" rel="nofollow">https://github.com/evanlong/security/blob/master/web/csrf/fr...</a>
评论 #3521477 未加载
moreorless超过 13 年前
Fantastic and inspirational writeup. Definitely will be forwarding the story to my nephew who is starting to show interest in programming.
darushimo超过 13 年前
thanks james and commenters saltcod and tmh88j for saying that the first few weeks are the hardest. I'm banging away at the google python exercises and nearly crying. knowing that other people are going through this headache too gives me a bit of confidence to truck through.
评论 #3518915 未加载
评论 #3518576 未加载
daylonsoh超过 13 年前
James, I'm kinda in a similar situation like your old-self and now you have a gun.
instakill超过 13 年前
Did you go about this project doing TDD/BDD?
评论 #3520006 未加载
评论 #3519847 未加载
评论 #3520465 未加载
mellifluousmind超过 13 年前
As someone with programming background, I actually wish there are more stories on the opposite direction (programmer who gets kickass awesome in UI design (HTML + CSS)).<p>I think that the complexity of CSS compatibility (what browser supports what not... even there are minor quirks between Firefox &#38; Chrome, not just IE.. don't get me started on IE7 &#38; 8 either), it is very easy to raise a white flag and say "that is it..I am going back to deal with backend only tasks, nothing that consumer will see on the surface).<p>Perhaps, OP already has a knack for UI design (as he/she mentioned in the post that he/she is a UI designer by trade before Ruby), so kudos for getting a nice grip on Rails. As for me, I wish I can master the UI design etc.
评论 #3518858 未加载
评论 #3519318 未加载
评论 #3518582 未加载
theDaveB超过 13 年前
I can't get the tryruby.org site to work properly. If I do anything wrong it just locks up and I have to refresh the browser window.<p>For instance at the "type 2 + 6" question, if I type 2+6 it freezes. If type 2 + 6 it's fine.<p>Running OSX Lion and Google Chrome.<p>Dave
fragileandys超过 13 年前
is this a joke? if so its funny... when i click the link i get: "Error establishing a database connection", haha
评论 #3518533 未加载