Code Monkey home page Code Monkey logo

gif_generator's People

Contributors

ryanflach avatar

Watchers

 avatar  avatar

gif_generator's Issues

Feedback

@ryanflach

  1. Use current_user in your controllers and views, no need to save it as an instance variable.
  2. The logic behind generating the class below should be taken care of somewhere else, perhaps in a helper.
#users/show.html.erb

<%= image_tag gif.image_path, class: "#{gif.category.name}-image-#{index + 1} img-responsive img-rounded" %><br />
  1. This logic should live in another helper: <% if current_user && !current_admin? %>. Whenever you find yourself doing && or || or > etc, you should create a new method that handles that logic.
  2. You should never ever ever query your database in your views. Query in your controller, then pass the data in via an instance method.
# admin/gifs/index.html.erb
<% Category.all.each do |cat| %>
  1. When validating our models, you'll want to validate the association not the foreign key. In your FavoriteGif model, you have:
  validates :gif_id, presence: true

Instead, you should be validating the association like so:

  validates :gif, presence: true
  1. Check into dependent: :destroy when you're destroying a gif and potentially destroying the category if that category has no other gifs. I'm pretty sure dependent destroy can help you out with that!
  2. Don't forget your unique constraints on the database level if you want your data to truly be unique ๐Ÿ‘

Good job with this!

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.