Posts by JeanMatheus • 126 points
9 posts
-
0
votes1
answer101
viewsA: How do I create DESTROY link with Slim?
Buenas, is wrong the way you are using the check inside the link Excluir. Vale recalls that the link_to is a method so what you send to it are the parameters, should not put the check there to show…
-
0
votes2
answers49
viewsA: How to use HATBM with multiple models
Buenas, I emerged the use of the association has_many model, :through table Follows description of the documentation: The has_many :through Association A has_many :through Association is often used…
-
0
votes2
answers178
viewsA: How to group dates according to month? Ruby + Mongoid
You can define a scope and from it return the objects ordered by start date, as an example: Mongoid MongoID # Provide the sorting options. Person.order_by([[:first_name, :asc], [:last_name, :desc]])…
-
0
votes2
answers241
viewsA: Active Record Rails 4
In this your situation I find it more valid to bring the filtered evaluations already, using the .where(condition) that so is generated sql correctly and makes a query only, example:…
-
1
votes1
answer66
viewsA: Redis in Rails 4
An alternative is to keep the .first of this relation: $redis = Redis::Namespace.new("suggestme", :redis => Redis.new) $redis.set("itens", Item.where(true).first)…
-
1
votes1
answer196
viewsA: Algorithm takes 5sec but the page takes 1.5m to load
Your method is a bit confusing, you don’t need to use the . all, see that the neck is the select of all items, one way to leave more ruby style would be: def get_tf_idf_recommendations itens =…
-
2
votes2
answers500
viewsA: Organize jQuery Ruby On Rails
An alternative is that I use to define a block in the layout to inject specific js files, which will only be used in that view, you can use so: <% content_for :footer do %> <%=…
-
4
votes1
answer199
viewsA: How to randomly shuffle an Array in Ruby?
You can use the method sample that you pass the amount you want to return, or still have the shuffle, follows an example: array = [1,2,3,4] #shuffle >> array.shuffle => [4, 1, 2, 3] #sample…
-
3
votes2
answers637
viewsA: How to insert values from a Select field into the database
If you are using Rails 4, have to look at the strog paramters, if you are allowing access to the attribute, follow example of the method: def your_model_params params.require(:account).permit(:tipo)…