scope

will paginate miscounting oddness with named scopes

谁说胖子不能爱 提交于 2019-12-22 08:13:27
问题 I recently broke up my query into 4 named scopes to make it easier to re-sort and will paginate which otherwise always worked fine now has problems calculating the number of pages. named_scope :loc, lambda { |id| { :conditions => ['location_id = ?', id ] } } named_scope :datem, lambda { |*args| { :joins => :scannables, :conditions => [ "scannables.bookdate BETWEEN ? and ?", (args[0].to_date || 3.days.from_now), (args[0].to_date+(args[1] || 3)) ], :group => 'scannables.hostel_id', :having =>

Namespacing with eval() and include() does not work as expected

↘锁芯ラ 提交于 2019-12-22 07:46:28
问题 I am just messing around and I've come across this: Doesn't work <?php namespace first{ include 'data:text/plain, <?php function a_func(){echo "hi";}'; a_func(); } namespace second{ include 'data:text/plain, <?php function a_func(){echo "bye";}'; a_func(); } [29-Apr-2016 14:12:42 America/New_York] PHP Fatal error: Cannot redeclare a_func() (previously declared in data:text/plain, <?php function a_func(){echo "hi";}:1) in data:text/plain, <?php function a_func(){echo "bye";} on line 1 Doesn't

Importing TypeScript Module located in path lower than current path throws Scope Error

こ雲淡風輕ζ 提交于 2019-12-22 07:36:29
问题 In an attempt to put together an AMD-friendly TypeScript application skeleton, I've run into a snag: I can't seem to drop down from my current path to import a module in another directory. I can import modules that are above, but below throws an error: TypeScript Error: The name ''../core/View'' does not exist in the current scope Here the is the structure of my (very basic) app: app/ - core/ - View.ts - views/ - HomeView.ts - Application.ts In my Application.ts file, I can successfully

C++ - Function declarations inside function scopes?

痞子三分冷 提交于 2019-12-22 05:34:08
问题 I was going through C++11 standard draft a while ago and came across this one (in §8.3.6, p. 204): void g(int = 0, ...); // OK, ellipsis is not a parameter so it can follow // a parameter with a default argument void f(int, int); void f(int, int = 7); void h() { f(3); // OK, calls f(3, 7) void f(int = 1, int); // error: does not use default // from surrounding scope } void m() { void f(int, int); // has no defaults f(4); // error: wrong number of arguments void f(int, int = 5); // OK f(4); //

Array size with const variable in C [duplicate]

柔情痞子 提交于 2019-12-22 05:11:33
问题 This question already has answers here : Can a const variable be used to declare the size of an array in C? (5 answers) Closed last year . I've found an interesting fact, and I didn't understand how is it works. The following piece of code just works perfectly. #include <stdio.h> int main(){ const int size = 10; int sampleArray[size]; typedef char String [size]; return 0; } Then, I tried to use only and only the constant variable with a global scope, and it's still fine. #include <stdio.h>

Array size with const variable in C [duplicate]

你说的曾经没有我的故事 提交于 2019-12-22 05:11:04
问题 This question already has answers here : Can a const variable be used to declare the size of an array in C? (5 answers) Closed last year . I've found an interesting fact, and I didn't understand how is it works. The following piece of code just works perfectly. #include <stdio.h> int main(){ const int size = 10; int sampleArray[size]; typedef char String [size]; return 0; } Then, I tried to use only and only the constant variable with a global scope, and it's still fine. #include <stdio.h>

Declaring Variables in @implementation

混江龙づ霸主 提交于 2019-12-22 04:49:09
问题 I saw an example in a book showing this code: @implementation ViewController { NSString *name; } Why not declare this in @interface ? What's the difference in declaring variables in @implementation instead of @interface ? Why declare this NSString in a scope? 回答1: The advantage of declaring ivars in the @implementation section is better encapsulation. That way, ivars don't have to appear in the .h file and are therefore not visible to external users of your class who only get to see the

Truly Private Variables in Python 3

本秂侑毒 提交于 2019-12-22 04:30:27
问题 So I know the way to make a variable "private" in python like this: class Foo: def __init__(self): self.__private = 'bar' This "works" and doesn't, as shown below: foo = Foo() '__private' in vars(foo) #False '_Foo__private' in vars(foo) #True Now, I understand this is the way to make private variables in python and I like this way. It allows you to mangle names so that no subclasses accidentally override this (because it begins with the class's name), and that nobody will accidentally use it.

Scopes as filters in rails_admin

↘锁芯ラ 提交于 2019-12-22 04:15:11
问题 I am using rails_admin in my app. I have some scopes on my models, following is an example: class User < ActiveRecord::Base scope :unconfirmed, where('confirmed_at IS NULL') end Is it possible in rails_admin to get access to those scope as a filter? Like you can in active admin. Like adding a button somewhere on in the users section. Thanks 回答1: I've managed to do this successfully by adding a custom rails_admin action. More details: https://github.com/sferik/rails_admin/wiki/Custom-action

Cannot access self:: when no class scope is active

十年热恋 提交于 2019-12-22 03:16:50
问题 I am trying to use a PHP function from within a public static function like so (I've shortened things a bit): class MyClass { public static function first_function() { function inside_this() { $some_var = self::second_function(); // doesnt work inside this function } // other code here... } // End first_function protected static function second_function() { // do stuff } // End second_function } // End class PayPalDimesale That's when I get the error "Cannot access self:: when no class scope