Commit Graph

14 Commits

Author SHA1 Message Date
Javi Martín
42d2e5b3ad Apply Rails/InverseOf rubocop rule
Not doing so has a few gotchas when working with relations, particularly
with records which are not stored in the database.

I'm excluding the related content file because it's got a very peculiar
relationship with itself: the `has_one :opposite_related_content` has no
inverse; the relation itself is its inverse. It's a false positive since
the inverse condition is true:

```
content.opposite_related_content.opposite_related_content.object_id ==
  content.object_id
```
2019-10-25 19:29:12 +02:00
Javi Martín
94d2496f8f Add missing has_many relations for users
Usually when we specify a `belongs_to` relations, we also specify its
equivalent `has_many`. That allows us to write, for example:
`topic.user.topics`.
2019-10-25 19:27:30 +02:00
Javi Martín
fda53a0a2a Remove unnecessary foreign_key options
When we specify `belongs_to :author`, ActiveRecord automatically uses
`author_id` as the foreign key.
2019-10-25 19:03:10 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Angel Perez
01c1ac2b10 Replace all occurrences of ActiveRecord::Base with ApplicationRecord 2019-04-17 17:40:56 +02:00
Julian Herrero
3ba961a2d7 Use double quotes in models 2019-03-14 17:25:43 +01:00
rgarcia
2b52d26d82 refactors notifications into concerns and shared examples 2017-12-14 16:15:30 +01:00
Bertocq
e4e78c8f16 Rubocop autocorrections 2017-09-14 15:08:35 +02:00
taitus
64774b0d2d Refactor topics controller. Add Common abilities. Add destroy action. 2017-09-06 13:30:12 +02:00
taitus
4539c5fa00 Refactor and tests. 2017-09-05 12:52:14 +02:00
taitus
a1d37fa6c4 Add order on topic index. 2017-09-05 12:51:08 +02:00
taitus
bc95b6f28d Add description as comment on topic. 2017-09-05 12:51:08 +02:00
taitus
bea393bcde Add comments to topics 2017-09-05 12:51:08 +02:00
taitus
43c17c3fc7 Add communities and topics 2017-09-05 12:51:08 +02:00