From e90a3138674afff285476c704a7f23a789d93218 Mon Sep 17 00:00:00 2001 From: capak07 <69026837+capak07@users.noreply.github.com> Date: Sun, 24 Jul 2022 22:01:46 -0300 Subject: [PATCH 1/2] Added mail methods --- Gemfile | 1 + Gemfile.lock | 7 ++++++ app/assets/stylesheets/application.css | 11 +++++++++- .../concerns/accounts_controller.rb | 6 +++-- app/mailers/user_mailer.rb | 2 +- app/views/accounts/show.html.erb | 2 +- app/views/layouts/mailer.html.erb | 1 - app/views/pages/about.html.erb | 2 +- app/views/pages/home.html.erb | 2 +- app/views/user_mailer/demo.text.erb | 8 +++---- app/views/user_mailer/welcome_email.html.erb | 17 +++++++++----- config/environments/development.rb | 19 ++++++++++++++++ config/environments/production.rb | 22 ++++++++++++++++++- test/mailers/previews/user_mailer_preview.rb | 4 ++++ 14 files changed, 85 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index f72e1f6..ce1af1f 100644 --- a/Gemfile +++ b/Gemfile @@ -73,4 +73,5 @@ group :test do gem "httparty" gem "uri" gem "net-http" + gem "sidekiq" end diff --git a/Gemfile.lock b/Gemfile.lock index 9c324a2..c5a17e6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,6 +83,7 @@ GEM xpath (~> 3.2) childprocess (4.1.0) concurrent-ruby (1.1.10) + connection_pool (2.2.5) crass (1.0.6) debug (1.6.1) irb (>= 1.3.6) @@ -193,6 +194,7 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rake (13.0.6) + redis (4.7.1) regexp_parser (2.5.0) reline (0.3.1) io-console (~> 0.5) @@ -203,6 +205,10 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + sidekiq (6.5.1) + connection_pool (>= 2.2.2) + rack (~> 2.0) + redis (>= 4.2.0) sprockets (4.1.1) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -262,6 +268,7 @@ DEPENDENCIES puma (~> 5.0) rails (~> 7.0.3, >= 7.0.3.1) selenium-webdriver + sidekiq sprockets-rails sqlite3 (~> 1.4) stimulus-rails diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 0ae6f4f..49872d0 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -66,7 +66,6 @@ body { -moz-background-size: cover; background-size: cover; -o-background-size: cover; - height: 682px; } h1 { color: hsl(0, 0%, 28%); @@ -94,4 +93,14 @@ body { 100% { background-position: 680px; } + } + + .connect{ + + min-height: 700px; + -webkit-background-size: cover; + -moz-background-size: cover; + background-size: cover; + -o-background-size: cover; + } } \ No newline at end of file diff --git a/app/controllers/concerns/accounts_controller.rb b/app/controllers/concerns/accounts_controller.rb index 0eef0c8..3ae3690 100644 --- a/app/controllers/concerns/accounts_controller.rb +++ b/app/controllers/concerns/accounts_controller.rb @@ -36,8 +36,8 @@ def transact # POST /accounts or /accounts.json def create @account = Account.new(account_params) - user = User.create(id: @account.id,name: @account.first_name + " " + @account.last_name,email: @account.email) - UserMailer.with(user: user).welcome_email.deliver_now + user = User.create(name: @account.first_name + " " + @account.last_name, email: @account.email) + UserMailer.with(user: user).welcome_email.deliver_now respond_to do |format| if @account.save format.json { render json: { status: 'success', message: 'Account was created', data: @account } } @@ -65,7 +65,9 @@ def update # DELETE /accounts/1 or /accounts/1.json def destroy + @account = Account.find(params[:id]) user = User.find(@account.id) + debugger @account.destroy user.destroy respond_to do |format| diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 077d10a..c0b96b7 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -5,7 +5,7 @@ class UserMailer < ApplicationMailer def demo - mail(to: "atharvabkadam@gmail.com", subject: "Test", message: "Test Email sent successfully") + mail(to: "akadam1@unb.ca", subject: "Test", message: "Test Email sent successfully") end diff --git a/app/views/accounts/show.html.erb b/app/views/accounts/show.html.erb index 71fc8f0..ce38025 100644 --- a/app/views/accounts/show.html.erb +++ b/app/views/accounts/show.html.erb @@ -6,5 +6,5 @@ <%= link_to "Debit", debit_account_path ,class: "btn btn-dark" %>

<%= link_to "Back to accounts", accounts_path, class: "btn btn-primary" %>
- <%= link_to "Destroy this account", @account, method: :delete, class: "btn btn-danger mt-3" %> + <%= link_to "Destroy this account",@account,method: :delete, class: "btn btn-danger mt-3" %> \ No newline at end of file diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index cbd34d2..62fb5d2 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -3,7 +3,6 @@ diff --git a/app/views/pages/about.html.erb b/app/views/pages/about.html.erb index 68dbb5c..10e4db0 100644 --- a/app/views/pages/about.html.erb +++ b/app/views/pages/about.html.erb @@ -1,3 +1,3 @@
-

About Us Page

+

About Us Page


\ No newline at end of file diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb index 9875949..a8c2589 100644 --- a/app/views/pages/home.html.erb +++ b/app/views/pages/home.html.erb @@ -3,7 +3,7 @@

Go to Accounts Page

<%= link_to "Accounts page", "accounts", class: "btn btn-dark text-white btn-outline btn-lg" %> -












+


diff --git a/app/views/user_mailer/demo.text.erb b/app/views/user_mailer/demo.text.erb index 147c223..54967f0 100644 --- a/app/views/user_mailer/demo.text.erb +++ b/app/views/user_mailer/demo.text.erb @@ -1,9 +1,7 @@ -Welcome to example.com, +Welcome to localhost:3000 =============================================== -You have successfully signed up to example.com, -your username is: - -To login to the site, just follow this link: +This was a test email sent by Atharva Kadam +You can delete this email Thanks for joining and have a great day! \ No newline at end of file diff --git a/app/views/user_mailer/welcome_email.html.erb b/app/views/user_mailer/welcome_email.html.erb index 0bda8a5..b8e3ef4 100644 --- a/app/views/user_mailer/welcome_email.html.erb +++ b/app/views/user_mailer/welcome_email.html.erb @@ -4,14 +4,21 @@ -

Welcome to example.com, <%= @user.name %>

+

Welcome to the Website, <%= @user.name %>

- You have successfully signed up to example.com, - your username is: <%= @user.login %>.
+ You have successfully registered account with us.
+ Your username is: <%= @user.login %>.

- To login to the site, just follow this link: <%= @url %>. + If you need to check your balance go to:
+ <%= @user.email%>

-

Thanks for joining and have a great day!

+

Thanks for joining and have a great day!
+ ---------------------------------------------------------------------------------- + This is an auto generated email, do not reply + ---------------------------------------------------------------------------------- +

+

+

AK Bank | Remote Address | Under Developement
\ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 8500f45..8244359 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -67,4 +67,23 @@ # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true + + + host = 'localhost:3000' + config.action_mailer.default_url_options = { :host => 'localhost:3000', protocol: 'http' } + + # config/environments/production.rb + +config.action_mailer.delivery_method = :test +host = 'example.com' #replace with your own url + +# SMTP settings for gmail +config.action_mailer.smtp_settings = { + :address => "smtp.gmail.com", + :port => 587, + :user_name => "atharvabkadam@gmail.com", + :password => "tuztyorvmdtisqpy", + :authentication => "plain", + :enable_starttls_auto => true +} end diff --git a/config/environments/production.rb b/config/environments/production.rb index 9cf4677..1ec47ad 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -89,5 +89,25 @@ end # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false + + + host = 'localhost:3000' + config.action_mailer.default_url_options = { :host => 'localhost:3000', protocol: 'http' } + + # config/environments/production.rb + +config.action_mailer.delivery_method = :test +host = 'example.com' #replace with your own url + +# SMTP settings for gmail +config.action_mailer.smtp_settings = { + :address => "smtp.gmail.com", + :port => 587, + :user_name => "atharvabkadam@gmail.com", + :password => "tuztyorvmdtisqpy", + :authentication => "plain", + :enable_starttls_auto => true +} + + end diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb index 957e12b..6f44ede 100644 --- a/test/mailers/previews/user_mailer_preview.rb +++ b/test/mailers/previews/user_mailer_preview.rb @@ -1,4 +1,8 @@ # Preview all emails at http://localhost:3000/rails/mailers/user_mailer class UserMailerPreview < ActionMailer::Preview + def welcome_email + user = User.create(name: "test", email: "akadam1@unb.ca") + UserMailer.with(user: user).welcome_email + end end From 126b668ba5a7b600448ab0aeb15d728ffa27ab77 Mon Sep 17 00:00:00 2001 From: capak07 <69026837+capak07@users.noreply.github.com> Date: Wed, 26 Jul 2023 09:40:43 -0300 Subject: [PATCH 2/2] Added CSS styling --- .idea/web-app.iml | 19 +++++++++++++++ .idea/workspace.xml | 23 +++++++++++-------- Gemfile | 3 +++ Gemfile.lock | 9 ++++++++ app/assets/stylesheets/application.css | 12 +++++++++- .../concerns/accounts_controller.rb | 18 ++++++++------- app/views/accounts/_header.html.erb | 4 ++-- app/views/accounts/transact.html.erb | 2 +- app/views/pages/about.html.erb | 5 +++- app/views/pages/home.html.erb | 3 +-- 10 files changed, 74 insertions(+), 24 deletions(-) diff --git a/.idea/web-app.iml b/.idea/web-app.iml index 79237a1..6753182 100644 --- a/.idea/web-app.iml +++ b/.idea/web-app.iml @@ -47,24 +47,38 @@ + + + + + + + + + + + + + + @@ -81,11 +95,13 @@ + + @@ -96,6 +112,9 @@ + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d8d0217..c255d01 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,11 @@ - + + + + + - { + "keyToString": { + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "WebServerToolWindowFactoryState": "false", + "last_opened_file_path": "C:/Users/Atharva K/source/repos/web-app", + "ruby.rails.projectView.checked": "true" } -}]]> +} @@ -133,6 +137,7 @@ 1658440916430 + diff --git a/Gemfile b/Gemfile index ce1af1f..417ba20 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,9 @@ gem "stimulus-rails" # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" +# Generate Fake data using Faker +gem 'faker', :git => 'https://github.com/faker-ruby/faker.git', :branch => 'master' + # Use Redis adapter to run Action Cable in production # gem "redis", "~> 4.0" diff --git a/Gemfile.lock b/Gemfile.lock index c5a17e6..e6592c8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: https://github.com/faker-ruby/faker.git + revision: 15a8bc35f489b2d5e06439c664363c779b125d6c + branch: master + specs: + faker (2.22.0) + i18n (>= 1.8.11, < 2) + GEM remote: https://rubygems.org/ specs: @@ -260,6 +268,7 @@ DEPENDENCIES bootsnap capybara debug + faker! http httparty importmap-rails diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 49872d0..6aa9437 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -60,7 +60,7 @@ body { display: flex; align-items: center; justify-content: center; - min-height: 683px; + min-height: 93vh; background: url('https://4kwallpapers.com/images/walls/thumbs_2t/8312.png') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; @@ -103,4 +103,14 @@ body { background-size: cover; -o-background-size: cover; } + + h2 { + color: hsl(184, 88%, 53%); + font-size: 20px; + font-weight: bold; + font-family: monospace; + letter-spacing: 2px; + cursor: pointer; + text-transform: uppercase; + } } \ No newline at end of file diff --git a/app/controllers/concerns/accounts_controller.rb b/app/controllers/concerns/accounts_controller.rb index 3ae3690..2c48245 100644 --- a/app/controllers/concerns/accounts_controller.rb +++ b/app/controllers/concerns/accounts_controller.rb @@ -7,12 +7,19 @@ class AccountsController < ApplicationController # GET /accounts or /accounts.json def index @accounts = Account.all - + respond_to do |format| + format.json { render json: { status: "success", data: @accounts } } + format.html { render :index } + end end # GET /accounts/1 or /accounts/1.json def show @account = Account.find(params[:id]) + respond_to do |format| + format.json { render json: { status: "success", data: @account } } + format.html { render :show } + end end @@ -65,14 +72,9 @@ def update # DELETE /accounts/1 or /accounts/1.json def destroy - @account = Account.find(params[:id]) - user = User.find(@account.id) - debugger @account.destroy - user.destroy - respond_to do |format| - redirect_to accounts_path - end + render json: { status: :deleted, message: 'Account was successfully destroyed.', data: @account } + end # PATCH /accounts/1/transact or /accounts/1/transact.json diff --git a/app/views/accounts/_header.html.erb b/app/views/accounts/_header.html.erb index 7bec61e..278cce4 100644 --- a/app/views/accounts/_header.html.erb +++ b/app/views/accounts/_header.html.erb @@ -18,8 +18,8 @@
- - + +
\ No newline at end of file diff --git a/app/views/accounts/transact.html.erb b/app/views/accounts/transact.html.erb index 21ca03d..9f5aab3 100644 --- a/app/views/accounts/transact.html.erb +++ b/app/views/accounts/transact.html.erb @@ -3,7 +3,7 @@ <%= form_with(model: @account, url: deposit_account_path) do |form |%>
  • <%= form.label :Enter_Amount, class: "text text-white"%> - <%= form.text_field :balance, class: "form-control", value: "0.0" %> + <%= form.text_field :balance, class: "form-control", value: "0" %>

  • <%= form.submit "Credit", class: "btn btn-dark bg-primary"%> <% end %> diff --git a/app/views/pages/about.html.erb b/app/views/pages/about.html.erb index 10e4db0..eb48216 100644 --- a/app/views/pages/about.html.erb +++ b/app/views/pages/about.html.erb @@ -1,3 +1,6 @@
    -

    About Us Page


    +
    +

    Connect Us


    +

    This is my 1st website built with interactive UI

    +
    \ No newline at end of file diff --git a/app/views/pages/home.html.erb b/app/views/pages/home.html.erb index a8c2589..e8aa604 100644 --- a/app/views/pages/home.html.erb +++ b/app/views/pages/home.html.erb @@ -1,7 +1,6 @@ -<<<<<<< HEAD
    -

    Go to Accounts Page

    +

    Go to Accounts Page

    <%= link_to "Accounts page", "accounts", class: "btn btn-dark text-white btn-outline btn-lg" %>