Commit b1c97097313bcc1404339b655337519503519b29
1 parent
fb61c078
Exists in
temp_ratings
Add relation to rate and comment.
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Showing
4 changed files
with
21 additions
and
4 deletions
Show diff stats
plugins/communities_ratings/controllers/communities_ratings_plugin_profile_controller.rb
1 | 1 | class CommunitiesRatingsPluginProfileController < ProfileController |
2 | 2 | |
3 | + before_filter :login_required | |
3 | 4 | # Inside a community, receive a ajax from the current logged person with its |
4 | 5 | # rate for the community. If the user already rated this commnity, update its |
5 | 6 | # rate value or else, create a new one |
... | ... | @@ -31,10 +32,10 @@ class CommunitiesRatingsPluginProfileController < ProfileController |
31 | 32 | @plugins = plugins |
32 | 33 | community_rating = get_community_rating(user, profile) |
33 | 34 | @actual_rate_value = if community_rating.value |
34 | - community_rating.value | |
35 | - else | |
36 | - 0 | |
37 | - end | |
35 | + community_rating.value | |
36 | + else | |
37 | + 0 | |
38 | + end | |
38 | 39 | |
39 | 40 | if request.post? |
40 | 41 | unless params[:comments][:body].empty? |
... | ... | @@ -42,6 +43,8 @@ class CommunitiesRatingsPluginProfileController < ProfileController |
42 | 43 | comment.author = current_user.person |
43 | 44 | comment.community = profile |
44 | 45 | comment.save |
46 | + community_rating.comment = comment | |
47 | + community_rating.save | |
45 | 48 | else |
46 | 49 | session[:notice] = _("You need to provide a decription to make a comment") |
47 | 50 | redirect_to action: :new_rating | ... | ... |
plugins/communities_ratings/db/migrate/20150707133834_add_community_rating_to_comments.rb
0 → 100644
plugins/communities_ratings/lib/community_rating.rb