Skip to content

Instantly share code, notes, and snippets.

@soilforlifeforms
Created August 6, 2015 13:49
Show Gist options
  • Save soilforlifeforms/093b0f9fb0fdefc83db5 to your computer and use it in GitHub Desktop.
Save soilforlifeforms/093b0f9fb0fdefc83db5 to your computer and use it in GitHub Desktop.
nomethoderror
undefined method `avatar_file_size=' for nil:NilClass
class GardenerDatasController < ApplicationController
def index
#1st you retrieve the group thanks to params[:group_id]
# @groups = current_user.groups
#2nd you get all the gardeners of this group
# @groups = @gardeners.group("LOWER(group_name)")
@gardeners = current_user.gardeners.includes(:group).order("LOWER(group_name)", "LOWER(first_name)")
respond_to do |format|
format.html # index.html.erb
format.xml {remder :xml => @gardeners}
end
end
def show
#1st you retrieve the group thanks to params[:group_id]
#@group = Group.find(params[:group_id])
#2nd you retrieve the comment thanks to params[:id]
@gardener = Gardener.find(params[:id])
@fuv = @gardener.follow_up_visits
#@impression = @fuv.follow_up_visit_impression
#@support_visit = @gardenener.support_visit
respond_to do |format|
format.html # show.html.erb
format.xml {render :xml => @gardener}
end
end
end
23 > fuv.follow_up_visit_impression.methods(true)
=> [:belongs_to_counter_cache_after_create, :belongs_to_counter_cache_before_destroy, :belongs_to_counter_cache_after_update, :autosave_associated_records_for_follow_up_visit, :avatar, :avatar=, :avatar?, :_post_process_callbacks, :_post_process_callbacks?, :_post_process_callbacks=, :_avatar_post_process_callbacks, :_avatar_post_process_callbacks?, :_avatar_post_process_callbacks=, :follow_up_visit, :follow_up_visit=, :build_follow_up_visit, :create_follow_up_visit, :create_follow_up_visit!, :id, :id=, :id_before_type_cast, :id?, :id_changed?, :id_change, :id_will_change!, :id_was, :reset_id!, :gardener_id, :gardener_id=, :gardener_id_before_type_cast, :gardener_id?, :gardener_id_changed?, :gardener_id_change, :gardener_id_will_change!, :gardener_id_was, :reset_gardener_id!, :future_plan, :future_plan=, :future_plan_before_type_cast, :future_plan?, :future_plan_changed?, :future_plan_change, :future_plan_will_change!, :future_plan_was, :reset_future_plan!, :issue, :issue=, :issue_before_type_cast, :issue?, :issue_changed?, :issue_change, :issue_will_change!, :issue_was, :reset_issue!, :positive, :positive=, :positive_before_type_cast, :positive?, :positive_changed?, :positive_change, :positive_will_change!, :positive_was, :reset_positive!, :negative, :negative=, :negative_before_type_cast, :negative?, :negative_changed?, :negative_change, :negative_will_change!, :negative_was, :reset_negative!, :general_comment, :general_comment=, :general_comment_before_type_cast, :general_comment?, :general_comment_changed?, :general_comment_change, :general_comment_will_change!, :general_comment_was, :reset_general_comment!, :follow_up_visit_id, :follow_up_visit_id=, :follow_up_visit_id_before_type_cast, :follow_up_visit_id?, :follow_up_visit_id_changed?, :follow_up_visit_id_change, :follow_up_visit_id_will_change!, :follow_up_visit_id_was, :reset_follow_up_visit_id!, :avatar_file_name, :avatar_file_name=, :avatar_file_name_before_type_cast, :avatar_file_name?, :avatar_file_name_changed?, :avatar_file_name_change, :avatar_file_name_will_change!, :avatar_file_name_was, :reset_avatar_file_name!, :avatar_content_type, :avatar_content_type=, :avatar_content_type_before_type_cast, :avatar_content_type?, :avatar_content_type_changed?, :avatar_content_type_change, :avatar_content_type_will_change!, :avatar_content_type_was, :reset_avatar_content_type!, :avatar_file_size, :avatar_file_size=, :avatar_file_size_before_type_cast, :avatar_file_size?, :avatar_file_size_changed?, :avatar_file_size_change, :avatar_file_size_will_change!, :avatar_file_size_was, :reset_avatar_file_size!, :avatar_updated_at, :avatar_updated_at=, :avatar_updated_at_before_type_cast, :avatar_updated_at?, :avatar_updated_at_changed?, :avatar_updated_at_change, :avatar_updated_at_will_change!, :avatar_updated_at_was, :reset_avatar_updated_at!, :defined_enums, :defined_enums?, :defined_enums=, :logger, :default_timezone, :schema_format, :timestamped_migrations, :dump_schema_after_migration, :default_connection_handler, :default_connection_handler?, :primary_key_prefix_type, :table_name_prefix, :table_name_prefix?, :table_name_suffix, :table_name_suffix?, :pluralize_table_names, :pluralize_table_names?, :store_full_sti_class, :store_full_sti_class?, :default_scopes, :cache_timestamp_format, :cache_timestamp_format?, :validation_context, :validation_context=, :_validate_callbacks, :_validate_callbacks?, :_validate_callbacks=, :_validators, :_validators?, :_validators=, :lock_optimistically, :lock_optimistically?, :attribute_aliases, :attribute_aliases?, :attribute_method_matchers, :attribute_method_matchers?, :attribute_types_cached_by_default, :attribute_types_cached_by_default?, :time_zone_aware_attributes, :skip_time_zone_conversion_for_attributes, :skip_time_zone_conversion_for_attributes?, :partial_writes, :partial_writes?, :_validation_callbacks, :_validation_callbacks?, :_validation_callbacks=, :_initialize_callbacks, :_initialize_callbacks?, :_initialize_callbacks=, :_find_callbacks, :_find_callbacks?, :_find_callbacks=, :_touch_callbacks, :_touch_callbacks?, :_touch_callbacks=, :_save_callbacks, :_save_callbacks?, :_save_callbacks=, :_create_callbacks, :_create_callbacks?, :_create_callbacks=, :_update_callbacks, :_update_callbacks?, :_update_callbacks=, :_destroy_callbacks, :_destroy_callbacks?, :_destroy_callbacks=, :record_timestamps, :record_timestamps?, :record_timestamps=, :nested_attributes_options, :nested_attributes_options?, :_commit_callbacks, :_commit_callbacks?, :_commit_callbacks=, :_rollback_callbacks, :_rollback_callbacks?, :_rollback_callbacks=, :_reflections, :_reflections?, :_reflections=, :aggregate_reflections, :aggregate_reflections?, :aggregate_reflections=, :include_root_in_json, :include_root_in_json?, :include_root_in_json=, :_ransackers, :_ransackers?, :_ransackers=, :upmin_model, :validates_attachment_content_type, :validates_attachment_file_name, :validates_attachment_presence, :validates_attachment_size, :validates_media_type_spoof_detection, :do_not_validate_attachment_file_type, :run_paperclip_callbacks, :read_store_attribute, :write_store_attribute, :serializable_hash, :to_xml, :from_xml, :as_json, :from_json, :read_attribute_for_serialization, :no_touching?, :touch, :transaction, :destroy, :save, :save!, :rollback_active_record_state!, :committed!, :rolledback!, :add_to_transaction, :with_transaction_returning_status, :remember_transaction_record_state, :clear_transaction_record_state, :restore_transaction_record_state, :transaction_record_state, :transaction_include_any_action?, :clear_aggregation_cache, :_destroy, :reload, :mark_for_destruction, :marked_for_destruction?, :destroyed_by_association=, :destroyed_by_association, :changed_for_autosave?, :clear_association_cache, :association_cache, :association, :run_validations!, :changed?, :changed, :changes, :previous_changes, :changed_attributes, :attribute_changed?, :attribute_was, :to_key, :attribute_method?, :query_attribute, :read_attribute_before_type_cast, :attributes_before_type_cast, :raw_write_attribute, :read_attribute, :method_missing, :respond_to?, :has_attribute?, :attribute_names, :attributes, :attributes_for_coder, :attribute_for_inspect, :attribute_present?, :column_for_attribute, :[], :[]=, :clone_attributes, :clone_attribute_value, :arel_attributes_with_values_for_create, :arel_attributes_with_values_for_update, :attribute_missing, :respond_to_without_attributes?, :lock!, :with_lock, :locking_enabled?, :valid?, :perform_validations, :validates_absence_of, :validates_acceptance_of, :validates_confirmation_of, :validates_exclusion_of, :validates_format_of, :validates_inclusion_of, :validates_length_of, :validates_size_of, :validates_numericality_of, :validates_presence_of, :run_callbacks, :errors, :invalid?, :read_attribute_for_validation, :validates_with, :to_param, :cache_key, :to_model, :to_partial_path, :assign_attributes, :attributes=, :sanitize_for_mass_assignment, :quoted_id, :populate_with_current_scope_attributes, :new_record?, :destroyed?, :persisted?, :delete, :destroy!, :becomes, :becomes!, :update_attribute, :update, :update_attributes, :update!, :update_attributes!, :update_column, :update_columns, :increment, :increment!, :decrement, :decrement!, :toggle, :toggle!, :init_with, :encode_with, :==, :eql?, :hash, :freeze, :frozen?, :<=>, :readonly?, :readonly!, :connection_handler, :inspect, :slice, :set_transaction_state, :has_transactional_callbacks?, :blank?, :present?, :presence, :acts_like?, :duplicable?, :deep_dup, :try, :try!, :in?, :presence_in, :to_query, :instance_values, :instance_variable_names, :to_json_with_active_support_encoder, :to_json_without_active_support_encoder, :to_json, :with_options, :html_safe?, :psych_to_yaml, :to_yaml, :to_yaml_properties, :`, :is_haml?, :pretty_print, :pretty_print_cycle, :pretty_print_instance_variables, :pretty_print_inspect, :require_or_load, :require_dependency, :load_dependency, :load, :require, :unloadable, :nil?, :===, :=~, :!~, :class, :singleton_class, :clone, :dup, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :to_s, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :extend, :display, :method, :public_method, :singleton_method, :define_singleton_method, :object_id, :to_enum, :enum_for, :gem, :silence_warnings, :enable_warnings, :with_warnings, :silence_stderr, :silence_stream, :suppress, :capture, :silence, :quietly, :class_eval, :pretty_inspect, :debugger, :breakpoint, :suppress_warnings, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__, :__id__]
<div class="panel panel-default">
<% if @gardener.support_visits.exists? %>
<table class="table">
<h2> Support Visits </h2>
<thead>
<tr>
<th> Date Created </th>
<th>Notes</th>
<th> Photo Attached </th>
</tr>
</thead>
<tr>
<% @gardener.support_visits.each do |sv| %>
<% if sv.date_created != nil %>
<th> <%= sv.date_created.to_s(:short) %> </th>
<% elsif sv.created_at != nil %>
<th> <%= sv.created_at.to_s(:short) %> </th>
<% else %>
<th> No date saved </th>
<% end %>
<th> <%= sv.notes %> </th>
<% if sv.avatar_file_size != nil %>
<th> Yes </th>
<% else %>
<th> No </th>
<% end %>
<th> <%= link_to "edit", edit_group_gardener_support_visit_path(sv.gardener.group.id, sv.gardener.id, sv.id) %>
</tr>
<% end %>
</table>
<% end %>
<% if @gardener.follow_up_visits.exists? %>
<table class="table">
<h2> Follow Up Visits </h2>
<thead>
<tr>
<th>date created</th>
<th> Garden info </th>
<th> Eating info </th>
<th> Selling info </th>
<th> Impression info </th>
<th> Picture attached </th>
</tr>
</thead>
<tr>
<% @gardener.follow_up_visits.each do |fv| %>
<td><%= fv.created_at.to_s(:short) %> </td>
<% if fv.follow_up_visit_garden != nil %>
<th> Yes
<%= link_to "edit", edit_follow_up_visit_follow_up_visit_garden_path(fv.id, fv.follow_up_visit_garden.id) %> </th>
<% else %>
<th> No
<%= link_to "Create", new_follow_up_visit_follow_up_visit_garden_path(fv.id) %> </th>
<% end %>
<% if fv.follow_up_visit_eating != nil %>
<th> Yes
<%= link_to "edit", edit_follow_up_visit_follow_up_visit_eating_path(fv.id, fv.follow_up_visit_garden.id) %> </th>
<% else %>
<th> No
<%= link_to "Create", new_follow_up_visit_follow_up_visit_eating_path(fv.id) %> </th>
<% end %>
<% if fv.follow_up_visit_selling != nil %>
<th> Yes
<%= link_to "edit", edit_follow_up_visit_follow_up_visit_selling_path(fv.id, fv.follow_up_visit_garden.id) %> </th>
<% else %>
<th> No
<%= link_to "Create", new_follow_up_visit_follow_up_visit_selling_path(fv.id) %> </th>
<% end %>
<% if fv.follow_up_visit_impression != nil %>
<th> Yes
<%= link_to "edit", edit_follow_up_visit_follow_up_visit_impression_path(fv.id, fv.follow_up_visit_garden.id) %> </th>
<% else %>
<th> No
<%= link_to "Create", new_follow_up_visit_follow_up_visit_impression_path(fv.id) %> </th>
<% end %>
<% if fv.follow_up_visit_impression.avatar_file_size =! nil %>
<th> Yes
<% else %>
<th> No
<% end %>
<% end %>
<% end %>
<!-- /groups/:group_id/gardeners/:id -->
</table>
<%= render 'form' %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment