diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index caa4bd3..9947d5b 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -46,7 +46,7 @@ class ContactsController < ApplicationController render :action => "list" end - def add + def new @contact = Contact.new @contact.customer_id = logged_user @@ -288,7 +288,7 @@ class ContactsController < ApplicationController end # Insert or update - def save + def create logger.info("BEGIN") if params["contact"]["id"] == "" # New contact @@ -337,7 +337,7 @@ class ContactsController < ApplicationController @groups[g.id] = 0 end } - render :action => "add" + redirect_to contacts_path end end diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index f27aa9c..6dfb5f1 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -25,7 +25,6 @@ module NavigationHelper def link_import_preview() "/contacts/import_preview" end def link_main_index() "/" end - def link_contact_save() "/contacts/save" end def link_contact_import() "/contacts/import" end def link_contact_choose() "/contacts/contact/choose" end @@ -34,7 +33,7 @@ module NavigationHelper end def link_contact_add_one - link_to(_('Add one contact'), :controller => "/contacts/contact", :action => "add") + link_to(_('Add one contact'), new_contact_path) end def link_contact_add_multiple diff --git a/app/models/contact.rb b/app/models/contact.rb index 768c7e1..877473a 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -59,7 +59,7 @@ class Contact < ActiveRecord::Base errors.add 'email', _('Please enter a valid email address.') unless valid_email?(self.email) # Already existing e-mail in contacts for this user is not allowed if self.new_record? - if Contact.find_first("email = '#{email}' and customer_id = #{customer_id}") + if Contact.find :first, :conditions => {:email => email, :customer_id => customer_id} errors.add('email', _('An account for your email address already exists.')) end end diff --git a/app/views/contacts/add.rhtml b/app/views/contacts/new.html.erb similarity index 89% rename from app/views/contacts/add.rhtml rename to app/views/contacts/new.html.erb index 77950fd..9b8fe6b 100644 --- a/app/views/contacts/add.rhtml +++ b/app/views/contacts/new.html.erb @@ -8,7 +8,7 @@
  • <%= _('Contacts') %> @@ -20,13 +20,7 @@
    - <%= - form_tag( - link_contact_save, - 'method' => 'post', - 'class' => 'two_columns' - ) - %> + <% form_tag( contacts_path, 'method' => 'post', 'class' => 'two_columns') do %> <%= form_input(:hidden_field, 'contact', 'id') %> <%= form_input(:hidden_field, 'contact', 'customer_id') %> @@ -74,6 +68,6 @@ - <%= end_form_tag %> + <% end %>