Posts by Fuad Saud • 500 points
17 posts
-
0
votes1
answer32
viewsA: Ruby - How to hit LOAD_PATH at development time?
I believe your concerns about this code should not exist. Other than what you say, this is the standard procedure for all applications with Ruby executable files: the executable is in bin/ and this…
-
1
votes1
answer104
viewsA: rake aborted! Ruby on Rails, Wordpress Plugin
This plugin seems to depend on the program bash available on UNIX operating systems such as Linux. Developing Ruby applications in Windows environments, although possible, is extremely difficult and…
-
0
votes1
answer224
viewsA: Update on Rails 4 using :has_many :through many relationship for many (has_and_belongs_to_many)
You have a callback calling the method Article#update_categories_up. This method is called at the controller line that calls the Article#update (if @article.update(article_params)). At that time the…
-
5
votes1
answer381
viewsA: Doubt about using send() in ruby
The method send allows you to call methods on any object dynamically. For example, imagine you have a class defined as follows: class Usuario def initialize(nome, email) @nome = nome @email = email…
-
2
votes3
answers2379
viewsA: When is the controller needed?
A way to see the layers of MVC is as follows:: Imagine your system as a little box. Visualization as a frontier The display layer is the part of your system that communicates with the outside world.…
-
0
votes1
answer289
viewsA: Extract hash in Ruby on Rails
There is an extension on ActiveSupport that allows you to extract keys from a Hash: my_hash = { city: { id: 1, created_at: '', name: 'test_city' }, uf: { id: 1, created_at: '', name: 'test_uf' } }…
-
4
votes2
answers2210
views -
1
votes1
answer231
viewsA: Doubt Dbref Mongodb
Mongodb is not able to mount this structure natively. The "Join" has to be done manually by your application - this logic could be abstracted by a library. That is, basically what you can do is:…
-
2
votes1
answer412
viewsA: What format is the image converted when requested by the browser?
No conversion type occurs: the image is simply serialized into an array of bytes and this is sent in the body of the HTTP response.
-
3
votes1
answer789
viewsA: How do HTTP request?
There are some tools for this type of technique (called Web Scraping). In Javascript some alternatives are: mechanize-js an adaptation of the famous Mechanize library (originally available in Perl…
-
2
votes1
answer75
viewsA: How to send errors and exceptions to the main output?
The simplest solution is to set the overall error output as the default output at the beginning of your script: $stderr = STDOUT STDOUT is the object of IO representing the standard output.…
-
1
votes1
answer115
viewsA: Database configuration using rspec-Rails
There is a rake task to prepare the test bench: bundle exec rake db:test:prepare This command creates the database, runs migrations and loads the schema. From there you can run the test suite.…
-
2
votes2
answers1173
viewsA: File request . txt via AJAX
Policy of the same origin There is a security feature in the browsers called Same-origin policy (Policy of the same origin) which is responsible for restricting access to available resources on…
-
3
votes4
answers11166
viewsA: Recover a file in GIT
Since you cloned the repository and soon after that deleted the file (the status deleted that you said), to get it back just rotate: git checkout <nome do arquivo excluído> This command…
-
0
votes2
answers178
viewsA: How to group dates according to month? Ruby + Mongoid
To group and sort ruby objects: headlines.group_by { |h| h.start_date.day } .values .map { |hs| hs.sort_by { |h| h.start_date } } If the idea is to delegate the responsibility of grouping and…
-
0
votes2
answers80
viewsA: How to manually delegate an object to Ruby
There is a solution to this problem in stdlib called Simpledelegator: http://ruby-doc.org/stdlib-2.1.0/libdoc/delegate/rdoc/SimpleDelegator.html…
-
1
votes1
answer85
viewsA: Using Jekyll to create a news for
In Jekyll there is a concept called "Collections". An example is the collection of post which is created by default with the directory files _post. To create a new collection you need to declare it…