Some CoffeeScript (verbosely commented for clarity)
# Override Rails handling of confirmation
$.rails.allowAction = (element) ->
# The message is something like "Are you sure?"
message = element.data('confirm')
def outstanding_totals | |
Invoice.with_state(:sent).to_a.sum(&:total_cents) | |
end | |
def drafted_totals | |
Invoice.with_state(:drafted).to_a.sum(&:total_cents) | |
end | |
def paid_totals | |
Invoice.with_state(:paid).to_a.sum(&:total_cents) |
@companies = Company.includes(:company_users).search(params[:q]).page(params[:page]).per(params[:per_page]||6) |
class Capybara::Session | |
def submit(element) | |
Capybara::RackTest::Form.new(driver, element.native).submit({}) | |
end | |
end | |
#in the test | |
fill_in 'Search', with: 'dice' | |
form = find '#search-form' # find the form |
class Country < ActiveRecord::Base | |
has_many :registrations | |
has_many :members | |
has_many :distribution_groups, :through => :members | |
end | |
class DistributionGroup < ActiveRecord::Base | |
has_many :members | |
has_many :countries, :through => :members | |
end |
#hellow | |
hellow | |
#hellow | |
width: 10px | |
white-space: nowrap | |
overflow: hidden | |
text-overflow: ellipsis |
[1] Time.now + 10.days | |
[2] 10.days.from_now | |
[3] -10.days.ago | |
[4] DateTime.now.days_ago(-10) | |
[5] Date.today + 10 |
<%= select_tag 'team_id', options_from_collection_for_select(@teams, "id", "name") %> | |
<script> | |
$(function(){ | |
$('#team_id').bind('change', function () { | |
var url = "/Teamleader/" + $(this).val() | |
if (url) { | |
window.location.replace(url); | |
} | |
return false; |
======= Prolbem ================================================================================================================= | |
I have installed : ruby-2.0.0,postgres-9.2 , now in rails app when I execute: | |
rake db:create , command I get: | |
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) | |
HINT: Use the same encoding as in the template database, or use template0 as template. | |
: CREATE DATABASE "my_db_name" ENCODING = 'unicode'....... | |
bin/rake:16:in `load' |
<<APP>> change this variables |