This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| show do | |
| panel "Participated Surveys" do | |
| farmer_id = resource.id | |
| table_for resource.forms do | |
| column("Name") {|form| link_to(form.name, admin_form_path(form))} | |
| column("Answers") { |form| link_to("answers", farmer_form_question_answers_admin_form_path(form, farmer_id: farmer_id))} | |
| column :created_at | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Rails 3.2.x model code | |
| class Model < ActiveRecord::Base | |
| #option 1 -- will cache the Time.now value! | |
| scope :expired, where('expire_date < ?', Time.now) | |
| #option 2 -- re-evaluates every time! | |
| scope :expired, -> { where('expire_date < ?', Time.now) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %div{class: "col-sm-12 affiliation-addresses"} | |
| .col-xs-6.col-sm-6.col-md-6 | |
| %div{:class => "form-group"} | |
| =f.label :category, :class => "control-label" | |
| =f.select(:category, [['Mail', 'mail'], ['Business', 'business']], {}, :class => "form-control") | |
| .small-field-error=field_validation_message(affiliation_address, :category) | |
| .col-xs-6.col-sm-6.col-md-6 | |
| %div{:class => "form-group"} | |
| =f.label :cep, :class => "control-label" | |
| =f.text_field(:cep, :class => "form-control") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| raw_params = | |
| {:user=> | |
| {:a=>"a", | |
| :b=> | |
| [{:c=>"c", :d=>"d"}, | |
| {:c=>"c", :d=>"d"}, | |
| {:c=>"c", :d=>"d"}, | |
| {:c=>"c", :d=>"d"}, | |
| {:c=>"c", :d=>"d"}]}} | |
| params = ActionController::Parameters.new(raw_params) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% blog.tags.each do |tag, articles| %> | |
| <li><%= link_to "#{tag} (#{articles.size})", tag_path(tag) %></li> | |
| <% end %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: UTF-8 | |
| require 'net/http' | |
| require 'net/https' | |
| require 'uri' | |
| module Literature | |
| class BibliographyDownloader | |
| def self.download | |
| uri = URI.parse(WebsitePrep.config.svn_url) | |
| base = Net::HTTP.new(uri.host, uri.port) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [4] pry(main)> Topic.connection.object_id | |
| => 84952140 | |
| [5] pry(main)> Questionnaire.connection.object_id | |
| => 84952140 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WhateverController < ApplicationController | |
| def index | |
| sort_order = ["asc", "desc"].include?(params[:order]) ? params[:order] : 'asc' | |
| sort_by = ["name", "address"].include?(params[:sortby]) ? params[:sortby] : 'name' | |
| @users = User.all.order(sort_by => sort_order) | |
| render 'v1/users/index' | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pry -r active_support/core_ext | |
| /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/number_helper.rb:3:in `<module:NumberHelper>': uninitialized constant ActiveSupport::Autoload (NameError) | |
| from /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/number_helper.rb:2:in `<module:ActiveSupport>' | |
| from /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/number_helper.rb:1:in `<top (required)>' | |
| from /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/core_ext/numeric/conversions.rb:2:in `require' | |
| from /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/core_ext/numeric/conversions.rb:2:in `<top (required)>' | |
| from /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/core_ext/numeric.rb:3:in `require' | |
| from /home/jhedtrich/.rvm/gems/ruby-2.1.5/gems/activesupport-4.2.0/lib/active_support/core_ext/numeric.rb:3:in `<top (required)>' | |
| from /home/j |