|
Ruby on Rails (aka Rails) While I'm admittedly still an amateur web developer, I've been a professional programmer for years, and I've always dabbled in web development. I'm currently a senior at UConn, and I've been working on an independent study project with a professor to create a simple two tier web application (eventually for my own purposes; the project is catered to my interests). I started out the project using javascript/ajax/php/css/sql, and got a simple semblance of a working webapp up after a month or so. Adding functionality was slow going, in part because I was new to php, and because I'm a bit clumsy with debugging web applications in general. Well, I was reading some rogue post here in SH/SC, where some wise fella said something along the lines of "you'd never run into this problem if you were using rails, and it would have taken you 10x less time to get here". Well this prompted ol' mrsaturn to start reading. Rails? What is rails? Rails is really just a streamlined and simplified way to create web applications that are heavily database dependent. The syntax is simple, installation is a breeze, and it's got a decent learning curve. It can run on a windows machine or linux, as well as ol' Mac OSX. With Rails,
Resources
Applications that Use Rails Here's some sample apps that use rails (I don't own any of these, they're just to show how drat cool it is) Typo is a web blogging service Worth note I'm currently working on integrating Hobo into my application. Hobo is an application builder for rails. It's basically the easiest way to get a user interface (log in/log out, etc) into your pages without having to think about it, and it works. The development team for hobo is very responsive, and helpful to my newbie woes. It's also got great ajax stuff built in, like the ability to edit fields in a record on the fly, if you're the right user. Check out their screencasts. So yeah, I mean, I'm in love with rails. Use this thread for whatever you want - over it, ask for help, tout its abilities, or whatever you see fit. If y'all have working webapps that use rails, or want me to include them in the OP, let me know! MrSaturn fucked around with this message at 19:11 on Aug 8, 2007 |
# ? Aug 8, 2007 18:57 |
|
|
# ? May 15, 2024 02:59 |
|
Hobo is located at https://www.hobocentral.net - might want to edit your link.
|
# ? Aug 8, 2007 19:08 |
|
Link should go to http://hobocentral.net/ Thanks for posting about Hobo -- I came into this thread for the sole reason of asking about an auth framework.
|
# ? Aug 8, 2007 19:09 |
|
Fixed the link, thanks =) Are there any experienced hobo users here? I'm currently filling up a thread in their dev forum because I can't get textile to work with it =/
|
# ? Aug 8, 2007 19:10 |
|
I'm really not a fan of Rails for the most part, but sticking to the thread topic, I will say that the logging (especially in development mode) is the most thorough I've ever seen. It's wordy as hell, but pretty much anything you would ever need is in there, provided you can grep your way to it. Breakpoints and the Script Console are pretty neat, too. I like that they made RoR apps as easy to debug as they are to program in the first place.
|
# ? Aug 8, 2007 20:22 |
|
ANAmal.net posted:I'm really not a fan of Rails for the most part, but sticking to the thread topic, I will say that the logging (especially in development mode) is the most thorough I've ever seen. It's wordy as hell, but pretty much anything you would ever need is in there, provided you can grep your way to it. Agreed, I usually tail the development log all the time and it's incredibly useful. It really does show you everything.
|
# ? Aug 8, 2007 21:10 |
|
In my opinion you can see a lot about languages from how they solve simple problems. So, for how would the following PHP code look in RoR?php:<? $result = mysql_query("select * from people order by lastname asc"); if (!$result) throw new Exception(mysql_error()); echo '<table>'; while ($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td>', $row['lastname'], '</td>'; echo '<td>', $row['firstname'], '</td>'; echo '<td>', $row['age'], '</td>'; echo '</tr>'; } echo '</table>'; ?>
|
# ? Aug 8, 2007 22:05 |
|
ANAmal.net posted:Breakpoints and the Script Console are pretty neat, too. I like that they made RoR apps as easy to debug as they are to program in the first place. I probably shouldn't even post in this thread, not having used Rails yet (started reading Ruby tutorials the other day, though, as my new job may have me doing some Rails work) but: how are the mentioned tools different from using e.g. Firebug or the Web Developer FF extension? I'm a Django person, so if anyone who's well versed in RoR wants to have a discussion about the differences/similarities between the two frameworks or their approaches to problems, I'd be game. (...and will I be the only RoR user who has a dislike for the David Hanssen style of "arrogance and overstatement is awesome" showmanship? )
|
# ? Aug 8, 2007 22:06 |
|
This is great, I was just beginning to get curious about Rails and then this thread pops up. Please, rails developers, do your best to sell me on Rails and get me really into it! I'd really like to learn it but need the motivation!
|
# ? Aug 8, 2007 22:15 |
|
RonaldMcDonald posted:In my opinion you can see a lot about languages from how they solve simple problems. So, for how would the following PHP code look in RoR? You'd have an HTML template file with all the HTML interspersed with <? ?> (I forget the exact delimiters) to print out variables (much like PHP, except logic isn't mixed with presentation). You wouldn't write any SQL at all; the table structure is determined automatically. Your controller class would basically have something like: code:
and people would be visible from the template file. Someone with access to a rails install can probably type this up in more detail. Edit: Like this guy below. floWenoL fucked around with this message at 00:07 on Aug 9, 2007 |
# ? Aug 8, 2007 22:32 |
|
RonaldMcDonald posted:how would the following PHP code look in RoR? If I wanted a page that listed all people ordered by lastname, I could do this: In app/controllers/person_controller.rb: code:
In app/models/person.rb: code:
In app/views/person/list.rhtml: code:
To highlight another convenience of Rails, if I have a site template, I simply put that in app/views/layouts/application.rhtml and it will wrap other views: code:
Novo fucked around with this message at 00:18 on Aug 9, 2007 |
# ? Aug 9, 2007 00:06 |
gently caress that HTML poo poo, Haml is where it's at.quote:The most basic element of Haml is a shorthand for creating HTML tags: There's a shitload more, including this as prepending a document with the XHTML 1.1 Doctype: code:
|
|
# ? Aug 9, 2007 01:10 |
|
http://haml.hamptoncatlin.com/ posted:Haml is a refreshing take that is meant to free us from the lovely templating languages we have gotten used to.
|
# ? Aug 9, 2007 01:23 |
leedo posted:...and replace it with another lovely templating language Okay, outside, right now, let's go I'm seriously addicted to Haml and Sass. It's almost as fast as ERB, looks beautiful, saves me typing (except for element attributes, but that's trivial), and is easier to read. Sass is genius - variables in CSS should have existed from the beginning. In any event, here are some other things I'm in love with: http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle - Heckle - This testing utility mutilates your code to see if it will still pass its tests. If it does, there may be something you're not testing completely. It breaks on some things (like any code that sends conditions to the DB), but otherwise is awesome to watch. http://chneukirchen.org/blog/archive/2007/01/announcing-test-spec-0-3-a-bdd-interface-for-test-unit.html - test/spec Beautiful, simple-language tests. code:
code:
|
|
# ? Aug 9, 2007 01:41 |
|
The Haml thing is a neat idea, but in practice doesn't everything just turn into div city? There's more than one tag in HTML for a reason.
|
# ? Aug 9, 2007 01:59 |
|
shopvac4christ posted:http://glu.ttono.us/articles/2006/12/19/tormenting-your-tests-with-heckle - Heckle - This testing utility mutilates your code to see if it will still pass its tests. If it does, there may be something you're not testing completely. It breaks on some things (like any code that sends conditions to the DB), but otherwise is awesome to watch. What the gently caress? This seems like a lovely and backwards way of doing things. Is it impossible to do any sort of static analysis in Ruby to get actual coverage instead of changing poo poo and waiting for it to break?
|
# ? Aug 9, 2007 02:01 |
|
I just started using Rails for a freelance web app I'm doing. I initially started the project in PHP and the time it was taking to get ANYTHING done in php was killing me, and I have a pretty good knowledge of the language. Its just the tediousness of having to tell your program EVERYTHING. Rails is a bit better at the instant gratification that I need. The app I'm going to wind up with is going to have more features, a cleaner design, and an easier time getting new features later. I can't say I could have done that with straight PHP (dont know nothing about stuff like Cake though)
|
# ? Aug 9, 2007 02:25 |
enki42 posted:What the gently caress? This seems like a lovely and backwards way of doing things. Is it impossible to do any sort of static analysis in Ruby to get actual coverage instead of changing poo poo and waiting for it to break? You mean code coverage? Like rcov? And regarding Haml - you can use all HTML elements. Using semantically incorrect divs is the fault of the programmer.
|
|
# ? Aug 9, 2007 02:25 |
|
enki42 posted:What the gently caress? This seems like a lovely and backwards way of doing things. Is it impossible to do any sort of static analysis in Ruby to get actual coverage instead of changing poo poo and waiting for it to break? Yes, it is impossible. Ruby is dynamic front, side and back. Nothing can be done about this without making it into a new language altogether. Therein lies most of it's power, but it's also quite simply static-analysis-proof. There are heuristic approaches that can analyze a few trivial cases statically, but nothing that is provably reliable.
|
# ? Aug 9, 2007 02:27 |
|
RonaldMcDonald posted:take this php and write it in ruby on rails Novo posted:no problem man I just want to make a quick note here. RonaldMcDonald's php code is less than 15 lines of simple, easy-to-follow php. Novo's ruby/rails code is almost 30 lines spread across 4 files (and ends his post with "Simple." ). If you've never heard of MVC or haven't used any web frameworks before you may think that Novo is nuts. He's not. Although the ruby he posted is definitely more complicated structurally than the equivalent non-framework php, this is actually how anything larger than a very simple dynamic website should be done, with presentation (html) separate from logic (db access et al). Edit: I know almost nothing about ruby or rails, but something that keeps me from diving in head first is...well, the concept of automated db access in general. Am I really going to let something write my sql for me? I really enjoy hammering out a nice query that does exactly what I need it to do, complete with inner/outer joins, unions, subselects, likes, ins, and whatever else is necessary with the appropriate indexes. For simple "select * from table where col=value" queries fine, do it for me, I won't mind. But for anything complex, can I take over? I know Hibernate allows me to take over when necessary. I don't yet trust the efficiency of a cruise controlled database. epswing fucked around with this message at 02:42 on Aug 9, 2007 |
# ? Aug 9, 2007 02:32 |
|
epswing posted:Edit: I know almost nothing about ruby or rails, but something that keeps me from diving in head first is...well, the concept of automated db access in general. Am I really going to let something write my sql for me? I really enjoy hammering out a nice query that does exactly what I need it to do, complete with inner/outer joins, unions, subselects, likes, ins, and whatever else is necessary with the appropriate indexes. For simple "select * from table where col=value" queries fine, do it for me, I won't mind. But for anything complex, can I take over? I know Hibernate allows me to take over when necessary. I don't yet trust the efficiency of a cruise controlled database. You can definitely write your own sql if you want to, and RoR doesn't stand in your way. You'd probably end up doing this for performance or non-portable stuff.
|
# ? Aug 9, 2007 03:00 |
|
epswing posted:
Yes you can always use straight up SQL. There are actually several levels of 'low level' sql you can do - it works out very nice. Common practice is to start out using just ActiveRecord and then optimize as needed. It works very well and you'd be surprised how little raw SQL exists in even high traffic sites. Usually adding an :include clause to a find is sufficient, and beyond that query optimization won't get you very far (or rather, that amount of work is better spent integrating memcached, which is pretty much THE way to scale no matter what language/framework you use)
|
# ? Aug 9, 2007 03:00 |
|
epswing posted:I just want to make a quick note here. Yes, there is a Person.find_by_sql method, among other things you can do to tweak the underlying SQL queries. In general you don't need to, as long as you use sensible indexes for the types of queries you know rails will be doing for you.
|
# ? Aug 9, 2007 03:05 |
|
RonaldMcDonald posted:In my opinion you can see a lot about languages from how they solve simple problems. So, for how would the following PHP code look in RoR? You could do it like this but you're not supposed to: code:
|
# ? Aug 9, 2007 03:16 |
|
epswing posted:I just want to make a quick note here. Yeah but RonaldMcDonald's code only does one thing. Novo's code is set up so that you can add another part for the page very easily. Novo's code is: - Readable - Very extensible (much easier to implement pagination on Ruby than on PHP, for example) - Lazy (select * from people, c'mon, every loving PHP person does this, EVERYONE, when they only need certain fields, it's fine when you have 10 records, but when you have 100k, not so fine.) Not to mention Novo's code produces valid html. Another thing not shown is that Neither Novo's code nor RonaldMcDonald's do any database setup. In php you setup the connection, RoR takes care of that for you. RoR saves in complexity when the application gets a bit... beefier. I would say that your average large RoR application is smaller than "grep -i 'select ' *.php" from your average smaller php application.
|
# ? Aug 9, 2007 03:20 |
|
RonaldMcDonald posted:In my opinion you can see a lot about languages from how they solve simple problems. So, for how would the following PHP code look in RoR? If you want to compare RoR with PHP you would need a framework of some sort, my own combination with adodb and smarty would be... php:<? $db = new Query(); $result = $db->exec( 'SELECT * FROM people ORDER BY lastname ASC' ); $tpl->assign( 'result', $result ); $tpl->display( 'person.tpl' ); ?> code:
On that note, RoR is neat but it's not the solution everyone claims it is. I just don't understand the whole buzz around RoR and why it's so great.
|
# ? Aug 9, 2007 03:37 |
|
deimos posted:Yeah but RonaldMcDonald's code only does one thing. Novo's code is set up so that you can add another part for the page very easily. I uh...maybe you didn't read my post.
|
# ? Aug 9, 2007 03:45 |
|
Like a few people here, I am mainly a PHP programmer and as such just like handling things myself. However, hearing that you can write SQL code yourself in RoR is somewhat interesting to me. On that note, is there any good books out there for RoR? Yes, there's the online documentation, but sometimes a book does a bit more for me. Anyone have any suggestions?
|
# ? Aug 9, 2007 04:32 |
|
legalcondom posted:On that note, RoR is neat but it's not the solution everyone claims it is. I just don't understand the whole buzz around RoR and why it's so great. Fewer dollar signs TheFlyingDutchman posted:On that note, is there any good books out there for RoR? Yes, there's the online documentation, but sometimes a book does a bit more for me. Anyone have any suggestions? http://www.pragmaticprogrammer.com/title/rails/ is sort of the standard. I have it, but it was free for me. You might also consider the Programming Ruby book too.
|
# ? Aug 9, 2007 05:05 |
|
legalcondom posted:On that note, RoR is neat but it's not the solution everyone claims it is. I just don't understand the whole buzz around RoR and why it's so great. Because Ruby is just a better language than PHP, and Rails meshes really well with the language. Notice how your PHP framework still requires you to write SQL, assign the result, and name the template manually.
|
# ? Aug 9, 2007 05:08 |
|
TheFlyingDutchman posted:On that note, is there any good books out there for RoR? Yes, there's the online documentation, but sometimes a book does a bit more for me. Anyone have any suggestions? The book on Rails is probably "Agile Web Development with Rails", by Dave Thomas. It touches on almost every aspect of the framework, but since the community likes to talk about how they'd rather "run on edge," parts of it get outdated rather quickly. You'll also find yourself reading the very sparsely documented API docs online rather often, but there's a project to spruce that up as well.
|
# ? Aug 9, 2007 05:13 |
|
Nolgthorn posted:You could do it like this but you're not supposed to code:
skidooer fucked around with this message at 05:59 on Aug 9, 2007 |
# ? Aug 9, 2007 05:35 |
|
floWenoL posted:Because Ruby is just a better language than PHP, and Rails meshes really well with the language. Notice how your PHP framework still requires you to write SQL, assign the result, and name the template manually. Actually I do have a query builder in my framework... that was just a basic example. I'd rather be in control of the queries though, I can imagine inexperienced Ruby developers are writing applications that will easily crumble under heavy load. Not knowing how the framework builds these queries for you and helps you do everything is a sure fire way to write horrible code. From my understanding, a lot of the popular RoR apps override the built ins anyway. I didn't mean to make it a PHP vs. RoR argument, you say "Ruby is just a better language" without stating why. I just wanted to understand why so many people are on this bandwagon because I just can't seem to figure out why I should use this language. I've tried it out but anything that ruby does, perl does better, and the whole rails thing... PHP is more stable and not really a moving target like RoR. edit: I can understand an argument about following proper code ethics, MVC and all of that...
|
# ? Aug 9, 2007 06:03 |
|
legalcondom posted:Actually I do have a query builder in my framework... that was just a basic example. I'd rather be in control of the queries though, I can imagine inexperienced Ruby developers are writing applications that will easily crumble under heavy load. I can't see inexperienced PHP developers doing much better, frankly. In fact, you'd have the added bonus of all the security holes. quote:I didn't mean to make it a PHP vs. RoR argument, you say "Ruby is just a better language" without stating why. I just wanted to understand why so many people are on this bandwagon because I just can't seem to figure out why I should use this language. I've tried it out but anything that ruby does, perl does better, and the whole rails thing... PHP is more stable and not really a moving target like RoR. First of all, you're confusing the framework (RoR) with the language itself. I've programmed Perl for years professionally and although it's not as bad as PHP, it has a lot of warts and gotchas. I'd like you to give me an example of something Ruby does that is done in Perl better. The only think I can think of is performance and just my own personal aesthetic sense. (I like how Perl looks better) And, um, saying that PHP is "stable" is a polite way of saying it's stagnant, I guess. I don't think that's true, as I believe PHP is still being actively developed, but there's a large legacy PHP4 codebase, which definitely holds back the community. Not to mention debacles like this. quote:edit: I can understand an argument about following proper code ethics, MVC and all of that... Ruby/RoR makes it easy. PHP does not. Simple as that. floWenoL fucked around with this message at 06:21 on Aug 9, 2007 |
# ? Aug 9, 2007 06:17 |
|
floWenoL posted:Ruby/RoR makes it easy. PHP does not. Simple as that. You keep comparing apples and oranges. Ruby is not an MVC framework, just like PHP. RoR, and PHP along with the several well developed frameworks like CakePHP, Symfony, and CodeIgniter make MVC development easy. Ruby itself does not make it easier, just like PHP itself does not.
|
# ? Aug 9, 2007 06:27 |
|
ryanmfw posted:You keep comparing apples and oranges. Ruby is not an MVC framework, just like PHP. RoR, and PHP along with the several well developed frameworks like CakePHP, Symfony, and CodeIgniter make MVC development easy. Ruby itself does not make it easier, just like PHP itself does not. I knew I should have clarified that. Ruby makes "following proper code ethics" easy. Rails makes "MVC" easy. Why PHP sucks as a language has already been covered namy times. The multitude of competing MVC frameworks, in my opinion, does not make MVC easy in PHP as the PHP programmer has to evaluate multiple frameworks to figure out what he needs, and PHP makes jumping in and just coding very easy, which is not necessarily a good thing. I don't think I compared apples and oranges in the rest of my post.
|
# ? Aug 9, 2007 06:35 |
|
What's that one blog about RoR where the guy is also a writer?
|
# ? Aug 9, 2007 08:01 |
|
Taliesin posted:What's that one blog about RoR where the guy is also a writer? why the lucky stiff, maybe?
|
# ? Aug 9, 2007 08:15 |
|
The Journey Fraternity posted:why the lucky stiff, maybe? That guy makes crazy stuff like this and this but wow is his stuff brain mashing when he gets off the serious note.
|
# ? Aug 9, 2007 10:57 |
|
|
# ? May 15, 2024 02:59 |
|
crazysim posted:That guy makes crazy stuff like this and this but wow is his stuff brain mashing when he gets off the serious note. Running random eval()s from the Interweb is a good idea c/d?
|
# ? Aug 9, 2007 11:57 |