This file contains 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
<%= form_for(resource, url: registration_path(resource_name), method: :post) do |f| %> | |
<%= f.fields_for :contacts do |contact_fields| %> | |
Nome: <%= contact_fields.text_field :name %> | |
<% end %> | |
<div class="register-buttons"> | |
<%= f.submit "Finish", class: "button button-primary", data: { disable_with: "Finish" } %> | |
</div> | |
<% end %> |
This file contains 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
--- ERR | |
uninitialized constant User::Aimed | |
--- Facing cols | |
id, aimer_id, aimed_id, aimed_kind (will be deprecated), aimed_type, created_at, updated_at |
This file contains 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
$(document).on 'page:update', (event) -> | |
$("#remove_users").on 'ajax:before', (xhr, settings) -> | |
user_ids = ($(user).val() for user in $(@).find("ul.active-users li.internal-user input:checked")) | |
external_users = ($(user).val() for user in $(@).find("ul.active-users li.external-user input:checked")) | |
console.log users | |
return false if internal_users.length is 0 and external_users.length is 0 | |
users = | |
params: | |
user_ids: user_ids | |
external_users: external_users |
This file contains 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
it 'should update rates when subject is accepted' do | |
previous_rate = subject.sale_rate | |
new_rate = BigDecimal.new(1) | |
subject.update_attribute(:sale_rate, new_rate) | |
expect { | |
subject.accept | |
}.to change { | |
subject.sale_rate | |
}.by new_rate - previous_rate |
This file contains 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 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 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 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 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
list = [128, 110, 60, 126] | |
list2 = [60, 110, 126] | |
res = list.each_with_index.each_with_object({}) {|(k,id), res| res[k] = id} | |
list 3 = list2.sort_by {|a| res[a]} |