Conversation
| @@ -0,0 +1,53 @@ | |||
| class CategoriesController < ApplicationController | |||
| before_action :set_category, only: [:show, :edit, :update, :destroy] | |||
|
|
||
| def create | ||
| @job = Job.find(params[:comment][:job_id]) | ||
| @comment = @job.comments.create(comment_params) |
There was a problem hiding this comment.
what if a user enters a blank comment? will they see an error?
| def index | ||
| @companies = Company.all | ||
| if params[:location] | ||
| @city = params[:location] |
There was a problem hiding this comment.
no need to set this as an instance variable, we can access it via one of the companies in the view
|
|
||
| def create | ||
| @company = Company.find(params[:contact][:company_id]) | ||
| @contact = @company.contacts.create(contact_params) |
There was a problem hiding this comment.
same here, what if a user fails to enter a contact's email? can they still create a contact? (i don't think the specs asked for this, but it's something to keep in mind!)
| has_many :jobs | ||
| has_many :contacts | ||
|
|
||
| def self.location_of_jobs_counter |
| group(:level_of_interest).count | ||
| end | ||
|
|
||
| def self.sorted_by_interest_level |
There was a problem hiding this comment.
i suggest breaking up the sorting by interest level and the grabbing the top three. this way, if you want to reuse the list of sorted jobs, you can!
|
|
||
| <%= form_for @comment do |f| %> | ||
|
|
||
| <%= f.hidden_field :job_id, :value => @job.id %> |
There was a problem hiding this comment.
we already talked about how nesting our routes would help us avoid the need to send hidden data 👍
| <a class="navbar-brand" href="#">Job Tracker</a> | ||
| </div> | ||
| <ul class="nav navbar-nav navbar-right"> | ||
| <li><a href="/companies">Companies</a></li> |
There was a problem hiding this comment.
leverage your rails helper methods here and use link_to and your path helpers!
| require 'rails_helper' | ||
|
|
||
| describe "User edits an existing category" do | ||
| scenario "a user can edit a category" do |
There was a problem hiding this comment.
don't forget sad paths!
| belongs_to :category | ||
| has_many :comments | ||
|
|
||
| def self.level_of_interest |
There was a problem hiding this comment.
i don't see tests for these custom model methods. don't forget to test every method you write!
hey @meganft - great work with this project. don't forget to handle errors and write tests for every single method you write in your models! let me know if you have questions about my comments or the scores 🎉
Rubric
1) Database, Relationships, and Migrations
2) Routes
3) Controllers
4) ActiveRecord
selfin models unnecessarily. Ruby enumerables are not used where ActiveRecord methods could provide the necessary functionality. The developer can explain the ActiveRecord methods they used and the relationships between ActiveRecord models.5) Views
6) User Experience
7) Testing