public

Protecting the content of public/ in a Rails app

二次信任 提交于 2019-11-27 00:31:00
问题 I'm maintaining a Rails app that has content in the public/ folder that will now need to be protected by a login. We're considering moving those folders of files into a path outside of public/ and writing a Rails controller to serve up the content. Before we begin writing this, I was curious if anyone else has ran into this sort of problem? I looked for some gems / plugins that might already do this but didn't find anything. Has anyone created a gem for this? 回答1: I've done this on a site

Friend declaration in C++ - difference between public and private

大兔子大兔子 提交于 2019-11-26 23:54:49
问题 Is there a difference between declaring a friend function/class as private or public? I can't seem to find anything about this online. I mean the difference between: class A { public: friend class B; }; and class A { private: //or nothing as the default is private friend class B; }; Is there a difference? 回答1: No, there's no difference - you just tell that class B is a friend of class A and now can access its private and protected members, that's all. 回答2: Since the syntax friend class B

Inline function cannot access non-public-API: @PublishedApi vs @Suppress vs @JvmSynthetic

穿精又带淫゛_ 提交于 2019-11-26 23:14:21
问题 In Kotlin, when I have a non-public member and an inline fun that calls it, there's a compilation error saying: Error:(22, 25) Kotlin: Public-API inline function cannot access non-public-API private fun f(): Unit defined in com.example I found several ways to call my function inside a public inline fun , but which is the best way to do it? Suppose I have a private fun f() { } . Then the options I found are: fun f() { } Just make it public. This is the baseline solution, but if the others turn

Call-time pass-by-reference has been removed [duplicate]

試著忘記壹切 提交于 2019-11-26 22:55:24
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Call-time pass-by-reference has been deprecated While it may be documented somewhere on the internet, I cannot find a solution to my problem. Since the PHP 5.4 update, pass-by-references have been removed. Now I have a problem with this section of code, and I hope somebody can see what I'm trying to do with it so that they can possibly help me with a solution to overcome my pass-by-reference problem. Below is

Why won't anyone accept public fields in C#?

你说的曾经没有我的故事 提交于 2019-11-26 20:59:57
Seems like every C# static analyzer wants to complain when it sees a public field. But why? Surely there are cases where a public (or internal) field is enough, and there is no point in having a property with its get_ and set_ methods? What if I know for sure that I won't be redefining the field or adding to it (side effects are bad, right?) - shouldn't a simple field suffice? Because it breaks encapsulation -- this is why most people use accessors heavily. However, if you think it's the right solution for your task, ignore it (meaning the strict encapsulation complaints) and do what's right

Advantage of set and get methods vs public variable [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-11-26 20:04:47
Possible Duplicate: Why use getters and setters? Is there any advantage to making methods to access private variables in your class instead of making the variable public? For example is the second case better than the first? //Case 1 public class Shoe{ public int size; } //Case 2 public class Shoe{ private int size; public int getSize(){ return size; } public void setSize(int sz){ size = sz; } } What I have seen someday on SO, as answer (written by @ChssPly76) why to use getters and setters Because 2 weeks (months, years) from now when you realize that your setter needs to do more than just

How to prevent public methods from being called from specific classes

青春壹個敷衍的年華 提交于 2019-11-26 17:47:34
问题 I have an existing class into which I want to add a method. But I want the method to be called only from a specific method from a specific class. Is there any way that I can prevent that call from other classes/methods? For example, I have an existing class A public final class A { //other stuff available for all classes/methods //I want to add a method that does its job only if called from a specific method of a class, for example: public void method() { //proceed if called from Class B

Does static method in PHP have any difference with non-static method?

大城市里の小女人 提交于 2019-11-26 16:36:02
问题 class t { public function tt() { echo 1; } } t::tt(); See?The non-static function can also be called at class level.So what's different if I add a static keyword before public ? 回答1: Except that, if you try to use $this in your method, like this : class t { protected $a = 10; public function tt() { echo $this->a; echo 1; } } t::tt(); You'll get a Fatal Error when calling the non-static method statically : Fatal error: Using $this when not in object context in ...\temp.php on line 11 i.e. your

The name '…' does not exist in the current context

心已入冬 提交于 2019-11-26 12:48:57
问题 I have a list within my Main() and I\'m trying to add an item to that list from within a variable. But it\'s throwing the error \"The name \'dogList\' does not exist in the current context\" Inside my addDog() method, dogList.Add() is not working due to above. namespace DoggyDatabase { public class Program { public static void Main(string[] args) { // create the list using the Dog class List<Dog> dogList = new List<Dog>(); // Get user input Console.WriteLine(\"Dogs Name:\"); string inputName

What if main method is inside “non public class” of java file?

♀尐吖头ヾ 提交于 2019-11-26 12:47:48
问题 I have a java file containing more than one class, out of which one is public. If main method is inside a non-public class. I can\'t run that java file. Why is that? and there is no compilation error as well. If so, how can I use that main method? 回答1: You can certainly override main method and it does not violate any compiler rules and hence you will not have any compiler errors. You check that inspite of the fact that you have more than one class a file that is declared as public is the