This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_next_approval | |
| next_approval = self.recommendation.approvals.build(:email => self.next_approver_email, :email => Email.find_by_email(next_approver_email)) | |
| next_approval.save if next_approver_email.present? && recently_approved? | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <% if @recommendation.errors.any? %> | |
| <div id="error_explanation"> | |
| <h2><%= pluralize(@recommendation.errors.count, "error") %> prohibited this recommendation from being saved:</h2> | |
| <ul> | |
| <% @.errors.full_messages.each do |msg| %> | |
| <li><%= msg %></li> | |
| <% end %> | |
| </ul> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| $(document).ready(function() { | |
| $('#next_approver_email_field').toggle(); | |
| $('#approval_checked').click(function() { | |
| $('#next_approver_email_field').show(); | |
| }); | |
| }); | |
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Approval < ActiveRecord::Base | |
| class ApproverEmailValidator < ActiveModel::EachValidator | |
| def validate_each(approval, attribute, value) | |
| approval.errors[attribute] << "must be a valid e-mail address in our system" unless is_valid_email?(value) | |
| end | |
| protected | |
| def is_valid_email?(address) | |
| User.find_by_email(address) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Approval < ActiveRecord::Base | |
| class ApproverEmailValidator < ActiveModel::EachValidator | |
| def validate_each(approval, attribute, value) | |
| approval.errors[attribute] << "must be a valid e-mail address in our system" unless is_valid_email?(value) | |
| end | |
| protected | |
| def is_valid_email?(address) | |
| User.find_by_email(address) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%= form_for @recommendation, :html => { :multipart => true} do |f| %> | |
| <% if @recommendation.errors.any? %> | |
| <div id="error_explanation"> | |
| <h2><%= pluralize(@recommendation.errors.count, "error") %> prohibited this recommendation from being saved:</h2> | |
| <ul> | |
| <% @recommendation.errors.full_messages.each do |msg| %> | |
| <li><%= msg %></li> | |
| <% end %> | |
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Approval < ActiveRecord::Base | |
| class ApproverEmailValidator < ActiveModel::EachValidator | |
| def validate_each(approval, attribute, value) | |
| approval.errors[attribute] << "must be a valid e-mail address in our system" unless is_valid_email?(value) | |
| end | |
| protected | |
| def is_valid_email?(address) | |
| User.find_by_email(address) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Started GET "/my-recommendations" for 127.0.0.1 at 2011-12-30 13:34:20 -0800 | |
| Processing by PagesController#recs as HTML | |
| User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1 | |
| Recommendation Load (0.4ms) SELECT "recommendations".* FROM "recommendations" INNER JOIN "approvals" ON "approvals"."recommendation_id" = "recommendations"."id" WHERE (approvals.count = 1 AND recommendations.user_id = 1) | |
| PGError: ERROR: aggregates not allowed in WHERE clause | |
| LINE 1: ...ecommendation_id" = "recommendations"."id" WHERE (approvals.... | |
| ^ | |
| : SELECT "recommendations".* FROM "recommendations" INNER JOIN "approvals" ON "approvals"."recommendation_id" = "recommendations"."id" WHERE (approvals.count = 1 AND recommendations.user_id = 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create | |
| @recommendation = Recommendation.new(params[:recommendation]) | |
| @recommendation.user_id = current_user.id | |
| @recommendation.approval.email = @recommendation.approval.next_approver_email | |
| respond_to do |format| | |
| if @recommendation.save | |
| format.html { redirect_to location_path, notice: 'Recommendation was successfully created.' } | |
| format.json { render json: @recommendation, status: :created, location: @recommendation } | |
| else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"registrations"} | |
| PUT /users(.:format) {:action=>"update", :controller=>"registrations"} |