diff --git a/db/migrate/20150814192230_add_institution_id_to_create_community_rating.rb b/db/migrate/20150814192230_add_institution_id_to_create_community_rating.rb new file mode 100644 index 0000000..56532f2 --- /dev/null +++ b/db/migrate/20150814192230_add_institution_id_to_create_community_rating.rb @@ -0,0 +1,11 @@ +class AddInstitutionIdToCreateCommunityRating < ActiveRecord::Migration + def up + change_table :community_ratings do |t| + t.belongs_to :institution + end + end + + def down + remove_column :community_ratings, :institution_id + end +end diff --git a/db/migrate/20150814192230_add_institution_id_to_create_community_rating_comment.rb b/db/migrate/20150814192230_add_institution_id_to_create_community_rating_comment.rb deleted file mode 100644 index 94051c6..0000000 --- a/db/migrate/20150814192230_add_institution_id_to_create_community_rating_comment.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddInstitutionIdToCreateCommunityRatingComment < ActiveRecord::Migration - def up - change_table :tasks do |t| - t.belongs_to :institution - end - end - - def down - remove_column :tasks, :institution_id - end -end diff --git a/lib/ext/comment.rb b/lib/ext/comment.rb deleted file mode 100644 index d952001..0000000 --- a/lib/ext/comment.rb +++ /dev/null @@ -1,18 +0,0 @@ -require_dependency "comment" - -Comment.class_eval do - attr_accessible :institution_id - - belongs_to :institution - - validate :verify_institution - - private - - def verify_institution - if self.institution_id != nil - institution = Institution.find_by_id self.institution_id - self.errors.add :institution, _("not found") unless institution - end - end -end diff --git a/lib/ext/community_rating.rb b/lib/ext/community_rating.rb new file mode 100644 index 0000000..78e78ac --- /dev/null +++ b/lib/ext/community_rating.rb @@ -0,0 +1,18 @@ +require_dependency "community_rating" + +CommunityRating.class_eval do + attr_accessible :institution_id + + belongs_to :institution + + validate :verify_institution + + private + + def verify_institution + if self.institution_id != nil + institution = Institution.find_by_id self.institution_id + self.errors.add :institution, _("not found") unless institution + end + end +end diff --git a/views/comments_extra_field.html.erb b/views/comments_extra_field.html.erb index b34fb30..a4d9849 100644 --- a/views/comments_extra_field.html.erb +++ b/views/comments_extra_field.html.erb @@ -6,5 +6,5 @@ <%= content_tag(:div, _("No institution found"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") %> - <%= hidden_field_tag "comments[institution_id]", "", id: "institution_selected" %> + <%= hidden_field_tag "community_rating[institution_id]", "", id: "institution_selected" %> diff --git a/views/communities_ratings_extra_fields_show_institution.html.erb b/views/communities_ratings_extra_fields_show_institution.html.erb index 05b234c..7cc4709 100644 --- a/views/communities_ratings_extra_fields_show_institution.html.erb +++ b/views/communities_ratings_extra_fields_show_institution.html.erb @@ -1,7 +1,7 @@ -<% if user_rating.comment and user_rating.comment.institution %> +<% if user_rating.institution %>