Module: ControllerMixins::Contacts
- Included in:
- ClientLogin::ContactsController, ContactsController
- Defined in:
- lib/controller_mixins/contacts.rb
Instance Method Summary collapse
Instance Method Details
#create!(path) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/controller_mixins/contacts.rb', line 3 def create!(path) @contact = Contact.new(params[:contact]) @contact.client = @client if @contact.save flash[:notice] = "Contact created successfully." redirect_to send(path, @contact.client, @contact) else flash.now[:error] = "There was a problem saving the new contact." render :action => 'new' end end |
#destroy!(path) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/controller_mixins/contacts.rb', line 26 def destroy!(path) @contact = Contact.find(params[:id]) if @contact.destroy flash[:notice] = "Contact was successfully deleted" redirect_to send(path) else flash.now[:error] = "There was a problem deleting the contact." render :action => 'show' end end |
#update!(path) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/controller_mixins/contacts.rb', line 15 def update!(path) @contact = Contact.find(params[:id]) if @contact.update_attributes(params[:contact]) flash[:notice] = "Contact updated successfully." redirect_to send(path) else flash.now[:error] = "There was a problem saving the contact." render :action => 'edit' end end |