Class: API::V1::ContactsController
- Inherits:
-
Faalis::APIController
- Object
- Faalis::APIController
- API::V1::ContactsController
- Defined in:
- app/controllers/api/v1/contacts_controller.rb
Instance Method Summary collapse
- #build_resource ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#index ⇒ Object
GET /api/v1/contacts.
- #resource_params ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#build_resource ⇒ Object
29 30 31 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 29 def build_resource @contact = ::Contact.new(resource_params) end |
#create ⇒ Object
10 11 12 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 10 def create create_or_update(:create) end |
#destroy ⇒ Object
22 23 24 25 26 27 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 22 def destroy ids = params[:id].split(",") @contacts = ::Contact.where(:id => ids) :destroy, @contacts @contacts.destroy_all end |
#index ⇒ Object
GET /api/v1/contacts
6 7 8 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 6 def index respond_with(@contacts) end |
#resource_params ⇒ Object
33 34 35 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 33 def resource_params params.require(:contact).permit(:id, :prefix, :first_name, :middle_name, :last_name, :suffix, :organization, :is_organization) end |
#show ⇒ Object
14 15 16 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 14 def show respond_with(@contact) end |
#update ⇒ Object
18 19 20 |
# File 'app/controllers/api/v1/contacts_controller.rb', line 18 def update create_or_update(:update) end |