Commit 9f38b70c0932d46c9045a7155f5ce171a41660da
Committed by
Marcos Pereira
1 parent
2fb87025
Exists in
stable-spb-1.5
using error_messages_for() to display errors
(cherry picked from commit 7dbd8a28e681cfbe074713ef8f5c1555baea92d5)
Showing
2 changed files
with
11 additions
and
12 deletions
Show diff stats
plugins/organization_ratings/controllers/organization_ratings_plugin_profile_controller.rb
@@ -37,20 +37,17 @@ class OrganizationRatingsPluginProfileController < ProfileController | @@ -37,20 +37,17 @@ class OrganizationRatingsPluginProfileController < ProfileController | ||
37 | end | 37 | end |
38 | 38 | ||
39 | def create_new_rate | 39 | def create_new_rate |
40 | - rating = OrganizationRating.new(params[:organization_rating]) | ||
41 | - rating.person = current_user.person | ||
42 | - rating.organization = profile | ||
43 | - rating.value = params[:organization_rating_value] if params[:organization_rating_value] | 40 | + @rating = OrganizationRating.new(params[:organization_rating]) |
41 | + @rating.person = current_user.person | ||
42 | + @rating.organization = profile | ||
43 | + @rating.value = params[:organization_rating_value] if params[:organization_rating_value] | ||
44 | 44 | ||
45 | - if rating.save | ||
46 | - @plugins.dispatch(:organization_ratings_plugin_rating_created, rating, params) | ||
47 | - create_rating_comment(rating) | 45 | + if @rating.save |
46 | + @plugins.dispatch(:organization_ratings_plugin_rating_created, @rating, params) | ||
47 | + create_rating_comment(@rating) | ||
48 | session[:notice] = _("%s successfully rated!") % profile.name | 48 | session[:notice] = _("%s successfully rated!") % profile.name |
49 | - else | ||
50 | - session[:notice] = rating.errors.messages.map{|field, message|"#{_(field.to_s)}: #{_(message.first)}"}.to_s | 49 | + redirect_to profile.url |
51 | end | 50 | end |
52 | - | ||
53 | - redirect_to profile.url | ||
54 | end | 51 | end |
55 | 52 | ||
56 | def create_rating_comment(rating) | 53 | def create_rating_comment(rating) |
plugins/organization_ratings/views/organization_ratings_plugin_profile/new_rating.html.erb
1 | +<%= error_messages_for 'rating' %> | ||
2 | + | ||
1 | <% config = env_organization_ratings_config %> | 3 | <% config = env_organization_ratings_config %> |
2 | <% if logged_in? %> | 4 | <% if logged_in? %> |
3 | <%= render :partial => "new_rating_fields" %> | 5 | <%= render :partial => "new_rating_fields" %> |
@@ -15,4 +17,4 @@ | @@ -15,4 +17,4 @@ | ||
15 | 17 | ||
16 | <div id='pagination-profiles'> | 18 | <div id='pagination-profiles'> |
17 | <%= pagination_links @users_ratings, :param_name => 'npage' %> | 19 | <%= pagination_links @users_ratings, :param_name => 'npage' %> |
18 | -</div> | ||
19 | \ No newline at end of file | 20 | \ No newline at end of file |
21 | +</div> |