Refactor the code

22 views
Skip to first unread message

Hem Chan

unread,
Jun 7, 2016, 9:10:27 PM6/7/16
to rubyonra...@googlegroups.com
How can i refactor the below code

class BlogPostsController < ApplicationController
def ex
@p_p = B.where(‘published_at <= ?’, Time.now)
@unp_p = BlogPost.where(‘published_at = ? OR published_at > ?’, nil,
Time.now)
end
end

--
Posted via http://www.ruby-forum.com/.

Dave Aronson

unread,
Jun 8, 2016, 7:25:48 AM6/8/16
to rubyonrails-talk
On Tue, Jun 7, 2016, Hem Chan <li...@ruby-forum.com> wrote:

> How would I optimize the following code?

and

> How can i refactor the below code

These smell like homework problems. Asking us to do your homework for
you will do Bad Things to your grades if your teacher finds out, your
professional reputation later, and of course your understanding of
what should actually be done. If you need help understanding the
concepts involved, you need to make that clear, so we can steer you
towards actual enlightenment rather than a plagiarized solution.

--
Dave Aronson, consulting software developer of Codosaur.us,
PullRequestRoulette.com, Blog.Codosaur.us, and Dare2XL.com.
Reply all
Reply to author
Forward
0 new messages