diff --git a/.idea/contactUs.iml b/.idea/contactUs.iml index 760f4d7..a4f4949 100644 --- a/.idea/contactUs.iml +++ b/.idea/contactUs.iml @@ -89,6 +89,9 @@ + + + @@ -103,6 +106,7 @@ + @@ -117,7 +121,7 @@ - + diff --git a/Gemfile.lock b/Gemfile.lock index 4fb3a12..477bf9a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -70,7 +70,7 @@ GEM arbre (1.5.0) activesupport (>= 3.0.0, < 7.1) ruby2_keywords (>= 0.0.2, < 1.0) - bcrypt (3.1.17) + bcrypt (3.1.18) bindex (0.8.1) bootsnap (1.11.1) msgpack (~> 1.2) @@ -114,7 +114,7 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jquery-rails (4.4.0) + jquery-rails (4.5.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) diff --git a/app/admin/emails.rb b/app/admin/emails.rb new file mode 100644 index 0000000..cec9973 --- /dev/null +++ b/app/admin/emails.rb @@ -0,0 +1,22 @@ +ActiveAdmin.register Email do + csv do + column :email + # preserve case + end + # See permitted parameters documentation: + # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters + # + # Uncomment all parameters which should be permitted for assignment + # + permit_params :email + # + # or + # + # permit_params do + # permitted = [:title, :description, :email, :phone] + # permitted << :other if params[:action] == 'create' && current_user.admin? + # permitted + # end + + end + \ No newline at end of file diff --git a/app/assets/stylesheets/email.scss b/app/assets/stylesheets/email.scss new file mode 100644 index 0000000..c94a4b8 --- /dev/null +++ b/app/assets/stylesheets/email.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the email controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ diff --git a/app/controllers/email_controller.rb b/app/controllers/email_controller.rb new file mode 100644 index 0000000..3dd8115 --- /dev/null +++ b/app/controllers/email_controller.rb @@ -0,0 +1,15 @@ +class EmailController < ApplicationController + skip_before_action :verify_authenticity_token + def index + end + + def create + @email = Email.create(message_params) + render json: {}, status: :created + end + + private + def message_params + params.permit(:email) + end +end diff --git a/app/helpers/email_helper.rb b/app/helpers/email_helper.rb new file mode 100644 index 0000000..37a644c --- /dev/null +++ b/app/helpers/email_helper.rb @@ -0,0 +1,2 @@ +module EmailHelper +end diff --git a/app/models/email.rb b/app/models/email.rb new file mode 100644 index 0000000..822e8dc --- /dev/null +++ b/app/models/email.rb @@ -0,0 +1,2 @@ +class Email < ApplicationRecord +end diff --git a/app/views/email/index.html.erb b/app/views/email/index.html.erb new file mode 100644 index 0000000..9343de6 --- /dev/null +++ b/app/views/email/index.html.erb @@ -0,0 +1,2 @@ +

Email#index

+

Find me in app/views/email/index.html.erb

diff --git a/config/routes.rb b/config/routes.rb index 56bfe6f..197d668 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,5 +2,6 @@ Rails.application.routes.draw do devise_for :admin_users, ActiveAdmin::Devise.config ActiveAdmin.routes(self) resources :messages, controller: 'messages' - # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html + resources :emails, controller: 'email' + end diff --git a/db/migrate/20230501112440_create_emails.rb b/db/migrate/20230501112440_create_emails.rb new file mode 100644 index 0000000..3b732a9 --- /dev/null +++ b/db/migrate/20230501112440_create_emails.rb @@ -0,0 +1,7 @@ +class CreateEmails < ActiveRecord::Migration[6.0] + def change + create_table :emails do |t| + t.string :email, null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ad798d8..f3bcd56 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_05_12_140948) do +ActiveRecord::Schema.define(version: 2023_05_01_112440) do create_table "active_admin_comments", force: :cascade do |t| t.string "namespace" @@ -38,6 +38,10 @@ ActiveRecord::Schema.define(version: 2022_05_12_140948) do t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true end + create_table "emails", force: :cascade do |t| + t.string "email", null: false + end + create_table "messages", force: :cascade do |t| t.string "title" t.text "description" @@ -45,6 +49,7 @@ ActiveRecord::Schema.define(version: 2022_05_12_140948) do t.string "phone" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false + t.string "name" end end diff --git a/test/controllers/email_controller_test.rb b/test/controllers/email_controller_test.rb new file mode 100644 index 0000000..6d600de --- /dev/null +++ b/test/controllers/email_controller_test.rb @@ -0,0 +1,9 @@ +require 'test_helper' + +class EmailControllerTest < ActionDispatch::IntegrationTest + test "should get index" do + get email_index_url + assert_response :success + end + +end