Skip to content

Instantly share code, notes, and snippets.

View jraczak's full-sized avatar

Justin Raczak jraczak

View GitHub Profile
class RequirementsController < ApplicationController
before_filter :load_project
def create
@requirement = @project.requirements.new(params[:requirement])
if @requirement.save
redirect_to @project, :notice => "Requirement has been successfully added."
else
redirect_to @project, :alert => "Warning! This requirement was not saved."
end
NoMethodError in Projects#show
Showing /Volumes/UserData/Users/jraczak/Desktop/nexus/app/views/requirements/new.html.erb where line #13 raised:
undefined method `include?' for nil:NilClass
Extracted source (around line #13):
10: <div class="field">
11: <%= f.label "Requirement Type:" %></br>
### ERROR OUTPUT ###
NoMethodError in Projects#show
Showing /Volumes/UserData/Users/jraczak/Desktop/nexus/app/views/requirements/_requirement.html.erb where line #5 raised:
undefined method `name' for nil:NilClass
Extracted source (around line #5):
ArgumentError: wrong number of arguments (1 for 0)
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.1/lib/active_record/associations/collection_proxy.rb:90:in `tap'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.1/lib/active_record/associations/collection_proxy.rb:90:in `send'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.2.1/lib/active_record/associations/collection_proxy.rb:90:in `method_missing'
from (irb):1
<p id="notice"><%= notice %></p>
<p>
<b>Name:</b>
<%= @project.name %>
</p>
<p>
<b>Description:</b>
<%= @project.description %>
def show
@project = Project.find(params[:id])
@requirement = @project.requirements.build
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @project }
end
end
def requirements_approved
total = requirements.count
approved = requirements.where(approved: true).count
approved.to_f / total
end
Can't connect to MySQL server on '/tmp/mysql.sock' (60)
Couldn't create database for {"reconnect"=>false, "encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql2", "database"=>"my_app_development", "host"=>"/tmp/mysql.sock", "pool"=>5, "password"=>nil}, charset: , collation:
No route matches {:action=>"edit", :controller=>"requirements", :project_id=>#<Project id: 1, name: "Royal Caribbean 2.0", description: "Design, Development, Strategy, Full services", start_date: "2011-03-07", end_date: "2012-08-25", created_at: "2012-03-07 18:36:40", updated_at: "2012-03-07 18:36:40", user_id: 1>, :id=>nil}
<p id="introduction">This is my introduction</p>
<p class="summary">I summarize the article here</p>
<p class="full-article">Here is my full article</p>