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 FiltersController < ApplicationController | |
def update | |
if params[:filter] | |
@filter = ::Filter.find params[:id] | |
@filter.attributes = params[:filter] | |
else | |
method = "add_or_remove_#{find_attribut}" | |
self.send(method) #if self.respond_to?(method) | |
return | |
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
class Job < ActiveRecord::Base | |
# there is a jobs_people table on client side | |
# has_and_belongs_to_many :people # how to workaround this? | |
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
class Job < ActiveRecord::Base | |
has_and_belongs_to_many :sources | |
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
class Person < ActiveRecord::Base | |
named_scope :job, lambda { |name| | |
{ :joins => :job, :conditions => { "job.name" => name } } | |
} | |
named_scope :car, lambda { |number| | |
{ :joins => :car, :conditions => { "car.number" => number } } | |
} | |
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
def test_should_scope_active | |
expected = { :conditions => { inactive => false }, :order => 'name asc' } | |
assert_equal expected, Person.active.proxy_options | |
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
user_input_date =~ /^[0-9]{8}$/ | |
user_input_date = Date.strptime("#{user_input_date[0..1]}.#{user_input_date[2..3]}.#{user_input_date[4..7]}", "%d.%m.%Y") |
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
/** | |
* Methods for extending Prototype | |
*/ | |
var Position = { | |
/** | |
* Centers an element against the parent or body | |
* parent should be display: relative | |
*/ | |
center: function(elem, parent){ | |
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
module Foo | |
def self.included base | |
include Foo::InstanceMethods | |
end | |
module InstanceMethods | |
def bar | |
@bar = 'Bar' | |
end | |
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
# paginator(people_path) is helper method returning html: | |
# the '\n' have to be wiped out | |
page << "$$('.paginate').invoke('update', '#{ j(paginator(people_path).gsub(/\n/,'')) }')" |
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
the issue i have: in the js.rjs i have to render a partial '_index', | |
but i wish i could render a 'index.html.erb', | |
like page.replace_html 'people', :template => 'index' | |
(but it ends up in a "Element.update("people", null);", thought the template is not empty) |
NewerOlder