Skip to content

Instantly share code, notes, and snippets.

@tarun-pacifica
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarun-pacifica/913a255a975c32244803 to your computer and use it in GitHub Desktop.
Save tarun-pacifica/913a255a975c32244803 to your computer and use it in GitHub Desktop.
Project 1
  • Always add methods to validate the presence of password, username, email;
	validates :username, presence: true, uniqueness: true, length: {minimum: 3}
	validates :email, presence:true
    validates :password_digest, presence:true, length; {minimum: 8}
  • When I register, if I have to sign in separately. This is a poor UX for the User. You should allow the user to log in automatically when they register as a user:
<!--userscontroller.rb-->
  def create
    @user = User.new(user_params)
    if @user.save
    session[:user_id] = @user.id
.
.

####Format and readability

  • Add a README file
  • Please make an effort to add comments to explain the purpose behind your custom code. especially for methods which are long, complicated and not very readable.
  • Dont just comment out dead code, this just adds clutter to your application. Please remove the dead code.
  • Try to avoid using rails scaffold, your app will end up with alot of boilerplate code and extraneous files that are not performing any function. Please delete the extraneous files and code.
  • It's not best practice to include your css in the application.css file. The preferred way is to include css in the files which reference particular views.
  • You should only retain background images for your landing page. Background images dont work that well behind forms and text, they are very 90's WWW.
  • For demo purposes, you should add some seed data to your app.
  • Best practice is not to interact with the model at the view level.
    <!--views/items/index.html.erb-->
    <% unless @items.empty? %>
      <% Item.all %>
        <h3>Please enter valid "search" name. Here are all the items currently in the Worthia database.</h3>
    <% end %>
    • Instead you should interact with the Model at Controller level and store the result in an instance variable....
    <!--Items Controller-->
    @items = Item.all
    ...then call the variable at the view level.
    <!--views/items/index.html.erb-->
    <% unless @items.empty? %>
      <% @items %>
        <h3>Please enter valid "search" name. Here are all the items currently in the Worthia database.</h3>
    <% end %>
  • Avoid naming variables in abstract manners that arent understandable to the developer.
<!--Items Controller-->
  @y = item
<!--what does @y refer to?-->
  • Ensure detailed, meaningful comments with your github pushes.
  • Deploy some of the more specialist ActiveRecord methods such as create, fetch, find_by & ruby methods such as map, inject, slice, ||=.....etc
  • After signing up your apps redirect to root_path, so they continue to see the login message. There is no need for this, instead redirect them straight to the items path as you have already logged them in.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment