Created
December 8, 2014 14:32
-
-
Save pier-oliviert/21da1357b7d69a7fa8a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class FollowersController < ApplicationController | |
| before_action :authenticate! | |
| def index | |
| @pictures = current_user.followers.pictures | |
| end | |
| end |
This file contains hidden or 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
| class Picture < ActiveRecord::Base | |
| scope :filter do |type| | |
| case type | |
| when 'hot' | |
| where('some SQL mumbo jumbo') | |
| when 'recent' | |
| order('pictures.created_at DESC') | |
| end | |
| end | |
| end |
This file contains hidden or 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
| class PicturesController < ApplicationController | |
| before_action :authenticate! | |
| #If a user is a guess, it redirects here. | |
| def index | |
| @pictures = Picture.filter(params.fetch(:f, 'all')) | |
| end | |
| end |
This file contains hidden or 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
| YourApp.routes.draw do | |
| resources :pictures | |
| resources :followers | |
| root to: 'pictures#index' | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment