Created
February 17, 2015 16:30
-
-
Save hjoseph96/73d970f00d83d563c210 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
no elegance, practicality | |
def self.practical | |
where("name LIKE ?", "%Practical%"); | |
end | |
# in controller | |
@useful_items = Item.practical | |
# in view | |
<% @useful_items.each do |item| %> | |
<div class="col-sm-3"> | |
<h5><%= item.name %></h5> | |
<%= link_to(image_tag(item.image_url), item_path(item)) %> | |
<p> | |
<%= item.description %> | |
</p> | |
</div> | |
<% end %> | |
addthree | |
eligible_orders = where.not(user_id: user_id) | |
eligible_orders.sample(3).each { |order| order.update(user_id: user_id) } | |
end | |
poppin | |
pop = Item.all.sort_by { |item| item.orders.count }.reverse.first | |
No ItemOrder tochy | |
item = Item.first | |
order = Order.first | |
item.orders << order | |
order.items << item | |
item.orders.include? order | |
=> true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment