GithubHelp home page GithubHelp logo

devalot / ror-example Goto Github PK

View Code? Open in Web Editor NEW
125.0 125.0 27.0 49 KB

Self-guided Ruby on Rails 3.1 Tutorial

Home Page: http://www.devalot.com/articles/2011/11/ror-example

License: The Unlicense

Ruby 98.88% JavaScript 1.12%

ror-example's People

Contributors

pjones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ror-example's Issues

Adhere better to established conventions

If you're making a tutorial app for newcomers, you should stick to the best practices and conventions agreed upon by the Rails and Ruby community (unless you have an explicit, intentional reason not to do so for certain cases).

A few things I noticed off the bat. You use a before_filter to set instance variables inside a controller. This is generally bad practice โ€” the folks at Rails Best Practices have highly downvoted a recommendation to do exactly that. My personal recommendation is in the comments of that post, but it boils down to: the contract between controller and view is instance variables. Contract fulfillment should be explicit.

Instead, define (memoized, ideally) a method that returns the collection object, and a method that returns the individual object (chained off the collection). Use these methods in the actions, and assign their return value to the expected instance variable.

Lastly, this is a minor nitpick, but you tend to overuse parentheses โ€” for instance, around every call to validates, has_many, belongs_to, etc. in your models. This style is almost completely nonexistent in the greater community.

Again, there are very minor nitpicks. Were this your personal Rails application, it's of no issue what particular coding conventions you choose to use. However, when writing guides for newcomers, I firmly believe that one should attempt to advocate the conventions of the community as a whole. Any deviation that one feels is necessary or a clear improvement over the existing convention should be documented and explained.

Feel free to shitcan this issue if you disagree with that premise. I encourage you to give it some thought, though.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.