Skip to content

Instantly share code, notes, and snippets.

@soilforlifeforms
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save soilforlifeforms/cbb91620fe04e919a360 to your computer and use it in GitHub Desktop.

Select an option

Save soilforlifeforms/cbb91620fe04e919a360 to your computer and use it in GitHub Desktop.
class AdminPageController < ApplicationController
def index
@gardener = Gardener.all
end
def show
@gardener = Gardener.all
end
end
undefined method `group_name' for nil:NilClass
class Gardener < ActiveRecord::Base
belongs_to :group
has_one :user, through: :group
end
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150304235455) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "gardeners", force: true do |t|
t.string "first_name"
t.string "last_name"
t.integer "contact_number", limit: 8
t.string "address"
t.integer "group_id"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "id_number", limit: 8
t.string "avatar_file_name"
t.string "avatar_content_type"
t.integer "avatar_file_size"
t.datetime "avatar_updated_at"
t.string "resume_file_name"
t.string "resume_content_type"
t.integer "resume_file_size"
t.datetime "resume_updated_at"
t.string "race"
end
add_index "gardeners", ["group_id"], name: "index_gardeners_on_group_id", using: :btree
create_table "groups", force: true do |t|
t.string "group_name"
t.string "area"
t.integer "user_id"
t.integer "avatar"
t.datetime "created_at"
t.datetime "updated_at"
t.string "group_picture_file_name"
t.string "group_picture_content_type"
t.integer "group_picture_file_size"
t.datetime "group_picture_updated_at"
end
create_table "users", force: true do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
t.integer "role"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
end
<table class="pretty">
<tr>
<th> <% link_to "name" %> </th>
<th> <% link_to "group" %> </th>
<th> <% link_to "area" %> </th>
<th> <% link_to "trainer" %> </th>
</tr>
<% @gardener.each do |gardener| %>
<tr>
<td> <%= gardener.first_name %> </td>
<td> <%= gardener.group %> </td>
<td> <%= gardener.user %> </td>
</tr>
<% end %>
</table>
<%#<%= will_paginate @gardener %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment