Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an initializer

In rails, when creating an initializer, is it as simple as adding a file to the config/initializer director or do I need to make changes elsewhere?

I'm asking because I keep getting errors every time I create an initializer for gems...and not sure if it's because I'm missing a step in creating initializers.

like image 948
user749798 Avatar asked May 15 '12 17:05

user749798


People also ask

What does an initializer do?

In Swift, an initializer is a special function that we use to create objects of a particular class, struct, or other type. Initializers are sometimes called constructors, because they “construct” objects.

What is an initializer in C++?

An initializer specifies the initial value of a variable. You can initialize variables in these contexts: In the definition of a variable: C++ Copy. int i = 3; Point p1{ 1, 2 };

What is an initializer in code?

An initializer is a special type of function that is used to create an object of a class or struct. In Swift, we use the init() method to create an initializer. For example, class Wall { ... // create an initializer init() { // perform initialization ... } }

How do you initialize an object?

Objects can be initialized using new Object() , Object. create() , or using the literal notation (initializer notation). An object initializer is a comma-delimited list of zero or more pairs of property names and associated values of an object, enclosed in curly braces ( {} ).


1 Answers

initializers are just files in config/initializers there is no other magic

like image 91
Frederick Cheung Avatar answered Oct 15 '22 15:10

Frederick Cheung