Skip to content

Instantly share code, notes, and snippets.

View rails-hub's full-sized avatar

Saqib R. rails-hub

  • Rails Hub
  • Lahore, Pakistan
View GitHub Profile
require 'open-uri'
require 'csv'
class Import < ActiveRecord::Base
attr_reader :account
attr_reader :file
has_one :import_file, class_name: 'Attachment::ImportFile', as: :attachable
belongs_to :importable, polymorphic: true
accepts_nested_attributes_for :import_file
class Accounts::ImportsController < Accounts::BaseController
before_filter :load_import, only: [:show, :update, :perform]
respond_to :html, :json
layout false
expose(:upload_members_form)
def create
import = Import.create(import_params)
class ToolDecorator < Draper::Decorator
include Trials::RatingToGrade
delegate_all
def grade
rating_to_grade(model.rating)
end
def trial_grade
class ToolPresenter < SimpleDelegator
require 'rubygems'
require 'action_view'
include ActionView::Helpers::DateHelper
def initialize(posts)
@posts = posts
end
A. Annotate the Code Above with an explanation of what's being done
One liner answer:
Its finding the missions with eager loading the milestones, company etc after applying the filters depending upon what filters(search/mission type id) has been passed to it.
B. List the params being acted upon
1. mission_type_id
2. search
C. List the variables being exposed for the view and what you expect they'll contain