Posts by Fladson Gomes • 136 points
12 posts
-
0
votes1
answer95
viewsA: How to mock a nonexistent class with Rspec Mock
I believe you can do it in many ways, but for your case that you need an Activerecord method, the best option would be mock_model. Something like: user = mock_model(User) allow(user).to…
-
0
votes2
answers904
viewsA: Add new fields in Migration ?
Yes, the path is to generate another Migration that will add the new fields. Something like: rails g migration AddNewFieldsToMembers class AddNewFieldsToMembers < ActiveRecord::Migration def…
-
0
votes1
answer104
viewsA: Ruby on Rails, how to improve the performance of the Hash to Activerecord transformation?
Apparently you have several entities in the consumed Hash. If it comes from a JSON, AC has a method that does all these assignments you’re doing on EdictBuild#generate. Model.new.from_json…
-
2
votes1
answer118
viewsA: Access level and hierarchy when checking checkboxes
Creates a scope that relates permissions to the user type (role), so you can get the permissions for the logged in user. In the view you would do something like: role.permissions.each…
-
1
votes1
answer2041
viewsA: HEROKU connect to mysql database
Mysql in Heroku is generated by an add-on, you will need to add it to your app in Heroku and follow the setup steps - https://elements.heroku.com/addons/cleardb Something like: # add cleardb add-ons…
-
2
votes3
answers494
viewsA: Installing ruby with rbenv
The rbenv is a very comprehensive but very useful tool when it is necessary to use several versions in different projects, so if you do not need it, the default installation should suit you well.…
-
1
votes3
answers982
viewsA: How to verify encrypted passwords with user input passwords in the database?
Complementing the answers, if your project is not specifically the hash generating algorithm, it is best to leave this function to specialized libraries, see Digestutils. import…
-
0
votes1
answer47
viewsA: Multiple Joins with Active record returning null
Why don’t you make a scope? scope :variation_csv, -> (product_id, size_id, color_id) { where product_id: product_id, size_id: size_id, color_id: color_id) }
-
0
votes2
answers249
viewsA: Truncate text and do not show unwanted characters with Rails
A Gem truncate_html maybe it’ll solve your problem Input example: <p>This is <em>my <strong>first</strong> post</em></p> Using the Gem: <%= truncate_html…
ruby-on-railsanswered Fladson Gomes 136 -
2
votes2
answers2327
viewsA: Is there any way to make a "git pull" without conflicts?
Daniel responded well, if there are no modifications locally, pull will be done without problems but if you have modified something, it is preferable to save the modifications before doing the pull:…
gitanswered Fladson Gomes 136 -
1
votes2
answers92
viewsA: How to take the signature of changed methods in a commit
I was able to solve this problem using the following combination: With a git Blame between the desired commit and your Parent I can extract which lines have been modified and take the respective…
-
3
votes2
answers92
viewsQ: How to take the signature of changed methods in a commit
So guys, I need to subscribe to all the methods that were changed in a commit, whether updated, removed or added. Example: In this commit The changed methods were: - br.ufrn.ase.Classe1.metodoB(int…