Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1079291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:50:48+00:00 2026-05-16T21:50:48+00:00

Does Agile Web Development With Ruby on Rails (Third Edition) teach best practices as

  • 0

Does Agile Web Development With Ruby on Rails (Third Edition) teach best practices as well as Rails coding?

My concern is that, as I use this book, I’m developing bad Rails coding habits resulting from the rather basic nature of the examples used in the book. Case-in-point:

The Product Model:

class Product < ActiveRecord::Base
  def self.find_products_for_sale
  find(:all, :order => "title" )
end

The Store Controller

class StoreController < ApplicationController
  def index
    @products = Product.find_products_for_sale
  end
end

The Store Index View

<h1>Your Pragmatic Catalog</h1>
<% @products.each do |product| -%>
  <div class="entry">
  <%= image_tag(product.image_url) %>
  <h3><%=h product.title %></h3>
  <%= product.description %>
  <div class="price-line">
  <span class="price"><%= product.price %></span>
  </div>
  </div>
<% end %>

Is it a best practice to declare a ‘helper’ function of sorts just to pull in all the available products in the catalog? Shouldn’t they have just done this?

@products = Products.find(:all, :order => "title");

I understand that they were probably just trying to demonstrate class-level methods, but they don’t add any caveat in the code stating that this isn’t really how you’re supposed to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:50:49+00:00Added an answer on May 16, 2026 at 9:50 pm

    I think in this particular you could have done that.

    But sometimes when doing complex finds, its better to abstract into a custom find statement. Applying model specific business rules etc, should be done inside the model instead of the controller. So its not exactly a bad idea.

    You can even use named_scopes to do the similar things. check out for this for more

    http://railscasts.com/episodes/108-named-scope

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I borrowed Agile Web Development with Rails from my local library, and for Mac
I'm going through the Agile Web Development with Rails tutorial. There are Products, LineItems,
I'm reading Agile web Development to learn Rails 3.0. The author is teaching us
Taking this snippet from the famous agile web development with rails book (most recent
I'm currently learning Ruby on Rails with the help of the Book Agile Web
It seems to me that Rails shines when building web-centric applications such as the
I'm trying to learn web-dev and decided to learn ruby on rails. I'm doing
How does a formal architecture specification fit in with agile development - if at
I'm reading the book Agile web developement with Rails 4Th editon, when he present
Does anyone know of any software that can be used to create Agile User

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.