# Send paramaters function @computed

**URL:** <https://meta.discourse.org/t/send-paramaters-function-computed/65568>\
**Category:** Development\
**Created:** [July 4, 2017, 9:42am UTC](https://meta.discourse.org/t/send-paramaters-function-computed/65568 "2017-07-04T09:42:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yohan](https://avatars.discourse-cdn.com/v4/letter/y/e99b99/32.png) [@Yohan](https://meta.discourse.org/u/Yohan)\
**Post date:** [July 4, 2017, 9:42am UTC](https://meta.discourse.org/t/send-paramaters-function-computed/65568/1 "2017-07-04T09:42:16Z")

</div>

Hi,  
I have a problem with a function in ES6. I have made a @computed function who calls a function in the ruby Tag component. It works fine.  
But i need to send a parameter from my ES6 function to the component… and i can’t do it…  
My ES6 function :

```javascript
@computed('site.tags_by_category') // here i think i have to send my parameter (category)
  tagsCategorie(reponse) {
        return reponse;
  },

```

My ruby function :

```ruby
def self.tags_by_category(category: nil)
      tags = exec_sql("SELECT t.name, t.topic_count FROM tags t, topic_tags tt, topics top WHERE t.topic_count>0 AND t.id=tt.tag_id AND tt.topic_id=top.id AND top.category_id IN 
      (SELECT id FROM categories WHERE id=? OR parent_category_id=?)", category, category)
  end

```

I want to send my category from ecmascript to my ruby function… Or if it’s possible to know the category ID in the ruby Tag component, it can be another solution…  
If someone can help me…  
Ty, and sorry for my english.

---

<div class="post-metadata">

**Author:** ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)\
**Post date:** [July 4, 2017, 2:51pm UTC](https://meta.discourse.org/t/send-paramaters-function-computed/65568/2 "2017-07-04T14:51:17Z")

</div>

Computed properties shouldn’t be sending values to the server. They are used to calculate values based on other values. For example, `area` would be computed based on `width * height`.

You should only submit data to the server when a user performs an action, for example hitting a “submit” button. You’d add an action to your controller or component, which would then send the AJAX request across.

---

<div class="post-metadata">

**Author:** ![Yohan](https://avatars.discourse-cdn.com/v4/letter/y/e99b99/32.png) [@Yohan](https://meta.discourse.org/u/Yohan)\
**Post date:** [July 5, 2017, 6:50am UTC](https://meta.discourse.org/t/send-paramaters-function-computed/65568/3 "2017-07-05T06:50:09Z")

</div>

ty for your answer Robin…  
In fact, i have no really action. I only want to display a tags cloud in my category page. So, i need to send the category to my Tag model.  
The other solution could be to get directly the current category in my component (so not need to send a parameter) but i don’t know how to do…

---

<div class="post-metadata">

**Author:** ![Yohan](https://avatars.discourse-cdn.com/v4/letter/y/e99b99/32.png) [@Yohan](https://meta.discourse.org/u/Yohan)\
**Post date:** [July 5, 2017, 10:01am UTC](https://meta.discourse.org/t/send-paramaters-function-computed/65568/4 "2017-07-05T10:01:00Z")

</div>

I have tried to used a top\_tags copy. So i can get the tags of my current category, it’s great… but i don’t have the tags count… How modify the top\_tags in order to have the tags count?

def self.top\_tags2(limit\_arg: nil, category: nil, guardian: nil)  
limit = limit\_arg || SiteSetting.max\_tags\_in\_filter\_list  
scope\_category\_ids = (guardian||Guardian.new).allowed\_category\_ids

```
if category
  scope_category_ids &= ([category.id] + category.subcategories.pluck(:id))
end

tags = DiscourseTagging.filter_allowed_tags(
  tags_by_count_query(limit: limit).where("topics.category_id in (?)", scope_category_ids),
  nil, # Don't pass guardian. You might not be able to use some tags, but should still be able to see where they've been used.
  category: category
)

tags.count(COUNT_ARG).map {|name, _| name}

```

end

The last lane only return the tags name, not the count… but i need to have the count to make the tags cloud…
