Commit 7dbd8a28e681cfbe074713ef8f5c1555baea92d5
Committed by
Marcos Pereira
1 parent
da0b1b3f
Exists in
ratings_minor_fixes
and in
3 other branches
using error_messages_for() to display errors
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 | 37 | end |
38 | 38 | |
39 | 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 | 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 | 50 | end |
52 | - | |
53 | - redirect_to profile.url | |
54 | 51 | end |
55 | 52 | |
56 | 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 | 3 | <% config = env_organization_ratings_config %> |
2 | 4 | <% if logged_in? %> |
3 | 5 | <%= render :partial => "new_rating_fields" %> |
... | ... | @@ -15,4 +17,4 @@ |
15 | 17 | |
16 | 18 | <div id='pagination-profiles'> |
17 | 19 | <%= pagination_links @users_ratings, :param_name => 'npage' %> |
18 | -</div> | |
19 | 20 | \ No newline at end of file |
21 | +</div> | ... | ... |