Other than that, if I'm not mistaken you should be able to use something like
@forum.badges.create!(badge:b,permission:p)
and
@forum.badges.find_by(id:b,permission:p)
Also, you can use
Badge.where.not(name:"none")
You can throw away half of your code and just use [`collection_check_boxes`](https://makandracards.com/makandra/32147-rails-4-introduced-collection_check_boxes) :sunglasses:
Other than that, if I'm not mistaken you should be able to use something like
```ruby
@forum.badges.create!(badge: b, permission: p)
```
and
```ruby
@forum.badges.find_by(id: b, permission: p)
```
Also, you can use
```ruby
Badge.where.not(name: "none")
```
threads=threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})",user_id,role_value,role_value,role_value,role_value)
threads=threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write}) OR (?)",user_id,role_value,role_value,role_value,role_value,Forum.find(forum).can_read?(user))
OR (false) (which will have no effect on the current query)
you could just wrap the query in a condition and not filter them any further.
Also, given that (#{can_read}) just mimics forum.can_read? in the SQL query, you don't need to include it anymore:
unlessforum.can_read?(user)threads=threads.where("forumthreads.user_author_id = ? OR (#{sticky_can_write})",user_id,role_value,role_value)end
Since this results in:
- `OR (true)` (which will always match) or
- `OR (false)` (which will have no effect on the current query)
you could just wrap the query in a condition and not filter them any further.
Also, given that `(#{can_read})` just mimics `forum.can_read?` in the SQL query, you don't need to include it anymore:
```ruby
unless forum.can_read?(user)
threads = threads.where("forumthreads.user_author_id = ? OR (#{sticky_can_write})", user_id, role_value, role_value)
end
```
You could use f.check_box instead, this would also generate a proper label tag.
You could use [`f.check_box`](http://api.rubyonrails.org/classes/ActionView/Helpers/FormBuilder.html#method-i-check_box) instead, this would also generate a proper label tag.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
whar are these for?
please don't shorten any text limits
You can throw away half of your code and just use
collection_check_boxes😎Other than that, if I'm not mistaken you should be able to use something like
and
Also, you can use
@@ -88,3 +88,3 @@threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", user_id, role_value, role_value, role_value, role_value)threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write}) OR (?)", user_id, role_value, role_value, role_value, role_value, Forum.find(forum).can_read?(user))if queryCouldn't you just use
forum.can_read?Since this results in:
OR (true)(which will always match) orOR (false)(which will have no effect on the current query)you could just wrap the query in a condition and not filter them any further.
Also, given that
(#{can_read})just mimicsforum.can_read?in the SQL query, you don't need to include it anymore:@@ -29,12 +29,28 @@<td><%= f.label :role_read_id, "Min. read role" %></td>You could use
f.check_boxinstead, this would also generate a proper label tag.where.not, if I'm not mistaken, was added in rails 5. We are using rails 4.
In that case I have no clue, but I definitely wasn't able to do that when I was a developer.