Posts by Londerson Araújo • 424 points
17 posts
-
7
votes1
answer2365
viewsA: How to get tomorrow’s date with Javascript?
Thus: var currentDate = new Date(); currentDate.setDate(currentDate.getDate() + 1);
-
1
votes1
answer125
viewsA: Problems configuring route in Rails
To compile the Coffeescript and Javascript Assets, Rails requires Javascript Runtime installed on your computer, if it does not have it, it returns this error during the Assets compilation. Usually…
ruby-on-railsanswered Londerson Araújo 424 -
0
votes1
answer230
viewsA: How to save data from another model. To archive information
First: "create the form" on the "employee show" page I don’t know if it’s necessary, by convention forms are in the "new.html.erb" view, but if that’s what you want, a form on the same page that…
ruby-on-railsanswered Londerson Araújo 424 -
0
votes2
answers183
viewsA: How to test with Rspec?
Before creating the test, if you use TDD (Test Driven Development), you have to know what your implementation, in case your controller’s action index, will return. In your case, it returns an array…
-
0
votes2
answers14
viewsA: How to set values for config’s of my Handler in tests?
Settings files are circumstantial. If in all your tests you are going to use them, you can create a file confi.rb, or even a fixture for him and make a require in your specs. If, for a test or…
-
1
votes1
answer191
viewsA: Is Gems Ruby or On Rails?
Gem are Ruby codes packaged to be distributed and reused by other projects, apps and so on... Just like packages are JAR in Java or as the Pecl of PHP. The Rubygems is the manager of these packages…
-
0
votes2
answers315
viewsA: How to render a json with the json_api adapter using Rails Serializer?
When you render in format json you can pass some optional parameters such as your user’s serializer as well as your adapter: def index render json: @users, serializer: UserSerializer, adapter:…
-
0
votes2
answers356
viewsA: Read TXT file on Rails
First you will have to read character by character and insert it into an array so you can create your hash that auto-increments its key. answers = [] array = "abc".each_char.map { |char| char }…
-
0
votes1
answer367
viewsA: Page loading Ajax + Jquery + Ruby on Rails
In case you are using two actions from two different controllers, so you will be redirected from one to the other via a redirect_to after the creation of Session. From what I understand you do not…
-
1
votes1
answer554
viewsA: Doubt about relationship between Rails tables
First you have a Line entity that has multiple Local entities, and if a Location belongs to only one Line you will have a Line that belongs to a Location. According to the same entity Line has…
-
1
votes2
answers135
viewsA: How to create a model from another model?
If User has_one Professional, then Professional has a user_id field. If you want you can reverse the order of the association, and use accepts_nested_attributes in a template. An alternative to your…
-
10
votes2
answers157
viewsA: Why are some "git" commands preceded by a dash and others by two dashes?
When you use with a dash is probably using a version shortcut command, for example, several programs have the command help, that you can access nome_do_programa --help or nome_do_programa -h In git…
gitanswered Londerson Araújo 424 -
0
votes1
answer60
viewsA: Definition of Wordpress-style roles
Well, it’s no secret, it’s the basic, step-by-step: List users and their role (admin, guest, student, etc...) By clicking the user can update its function. When visiting a page check if the user has…
-
1
votes1
answer43
viewsA: How to deal with the requirement of certain attributes in models that include a Concern in Rails?
Simple, before Activesupport::Concerns you needed to include a module of a lib, in Activerecord to be able to make use of a behavior, for example: User.my_custom_method Concerns, came to help in…
-
1
votes2
answers1260
viewsA: How to run unit tests on rspec?
Rspec tests behavior, while Unit Test (assuming this is the tool you are using for unit testing) tests the units of your application. You cannot run unit tests with a tool that runs behavior tests.…
-
1
votes2
answers947
viewsA: Add values from a column with Ruby
You can do as quoted in the other answer, only never call a model method in a view, because model does not communicate with view, and that is one of the fundamentals of MVC. You can call this method…
-
0
votes2
answers967
viewsA: How to create a test with Rspec to verify user feedback?
Your action index: def index @users = User.all respond_to do |format| format.json { render json: @users } end end You can test how many users your variable is returning: describe "GET 'index'" do it…