<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Szechuan SaaS</title>
    <description>The latest articles on DEV Community by Szechuan SaaS (@swesharif27).</description>
    <link>https://dev.to/swesharif27</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F94266%2F846b9e48-2d40-41ef-b560-e96e0bbc1d9f.jpg</url>
      <title>DEV Community: Szechuan SaaS</title>
      <link>https://dev.to/swesharif27</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swesharif27"/>
    <language>en</language>
    <item>
      <title>How to manage your Ruby on Rails project deployed on Heroku</title>
      <dc:creator>Szechuan SaaS</dc:creator>
      <pubDate>Thu, 08 Jul 2021 00:18:23 +0000</pubDate>
      <link>https://dev.to/swesharif27/ruby-on-rails-attendance-management-app-4p0a</link>
      <guid>https://dev.to/swesharif27/ruby-on-rails-attendance-management-app-4p0a</guid>
      <description>&lt;p&gt;Staring at a blank VS code editor can be intimidating when approaching a new project and I'll be sharing some helpful tricks that I used to maximize my productivity for my attendance management app.&lt;/p&gt;

&lt;p&gt;The primary functionality of this app goes as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Users will be able to manage attendance for each lecture.&lt;br&gt;
Once logged in the user will view the available lectures to the Teacher. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then after clicking the "Attendance log" under the lecture users will then have the ability to log attendance for the lecture with CRUD functionality. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Users will have sign in / out capability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Users will only be able to view their own students unless they are an admin user.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Productivity Setup
&lt;/h1&gt;

&lt;p&gt;I utilized notion as a primary source for managing my project listing my requirements and hosting my diagrams as well as any note taking with documentation I read during building my web app. I also created a Entity relationship diagram illustrate the relationships of my schema which you can see below:&lt;/p&gt;

&lt;h1&gt;
  
  
  Listing out requirements in notion
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P5JUR6C3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbw2uegumse8q938j50o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P5JUR6C3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbw2uegumse8q938j50o.png" alt="Image description" width="880" height="644"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Entity Relationship Diagram
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ONa6xsqT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9olclytasrc8bot40mo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ONa6xsqT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x9olclytasrc8bot40mo.png" alt="Image description" width="880" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Schema
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ActiveRecord::Schema.define(version: 2021_11_05_185536) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "attendances", force: :cascade do |t|
    t.string "student_name"
    t.integer "student_id"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.bigint "user_id"
    t.string "status"
    t.bigint "lectures_id"
    t.index ["lectures_id"], name: "index_attendances_on_lectures_id"
    t.index ["user_id"], name: "index_attendances_on_user_id"
  end

  create_table "lectures", force: :cascade do |t|
    t.string "name"
    t.string "description"
    t.integer "classroom_number"
    t.time "duration"
    t.bigint "user_id"
    t.index ["user_id"], name: "index_lectures_on_user_id"
  end

  create_table "students", force: :cascade do |t|
    t.string "student_name"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.bigint "lectures_id"
    t.bigint "user_id", null: false
    t.index ["lectures_id"], name: "index_students_on_lectures_id"
    t.index ["user_id"], name: "index_students_on_user_id"
  end

  create_table "teachers", force: :cascade do |t|
    t.string "teacher_name"
    t.string "teacher_type"
    t.bigint "user_id"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.index ["user_id"], name: "index_teachers_on_user_id"
  end

  create_table "users", force: :cascade do |t|
    t.string "email", default: "", null: false
    t.string "encrypted_password", default: "", null: false
    t.string "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.string "provider"
    t.string "uid"
    t.string "name"
    t.integer "role", default: 0
    t.index ["email"], name: "index_users_on_email", unique: true
    t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
  end

  add_foreign_key "attendances", "lectures", column: "lectures_id"
  add_foreign_key "students", "lectures", column: "lectures_id"
  add_foreign_key "students", "users"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Ruby on Rails naming conventions
&lt;/h1&gt;

&lt;p&gt;Here is a consolidated list of Naming Conventions in Ruby on Rails, that I have collected from the internet. I'm highlighting this because when you are creating your associations it's important to have the correct pluralization, otherwise your relationships between models will not work correctly.&lt;/p&gt;

&lt;p&gt;Model -&lt;br&gt;
Follows the convention of Class names of unbroken MixedCase letters&lt;br&gt;
Always Singular format of the corresponding Table Name in database&lt;br&gt;
file name for the Models should always be in lowercase. For Multiple words use '_'&lt;br&gt;
eg.: Order (table name: orders | file name: /app/models/order.rb )&lt;/p&gt;

&lt;p&gt;Database Table - &lt;br&gt;
Table names have all lowercase letters and underscores between words, also all table names need to be plural&lt;br&gt;
e.g. invoice_items, orders&lt;/p&gt;

&lt;p&gt;Files &amp;amp; Directories - &lt;br&gt;
Files and Directories are named using lowercase letters and '_' for multiple words formats&lt;br&gt;
Proper naming and pluralization is mandatory for the conventional functioning of Rails&lt;br&gt;
eg.: app/helpers/orders_helper.rb, app/models/order.rb&lt;/p&gt;
&lt;h1&gt;
  
  
  Creating migration associations
&lt;/h1&gt;

&lt;p&gt;When you create an association, Rails makes two major assumptions – first, that the class of the model your association points to is based directly off of the name of the association, and, second, that the foreign key in any belongs_to relationship will be called yourassociationname_id. Any time you go away from these defaults, you just need to let Rails know what kind of class to look for and which foreign key to use. This especially was useful in building my user table / model and acknowledging only my teacher and admin roles.  &lt;/p&gt;

&lt;p&gt;Teachers using the attendy web app will only be able to view their own lectures and students. I was able to setup functionality in the lectures controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class LecturesController &amp;lt; ApplicationController
  before_action :set_lecture, only: %i[ show edit update destroy ]

  # GET /lectures or /lectures.json
  def index
    if current_user == nil
      redirect_to users_sign_in_path
    else
      @lectures = Lecture.teachers_lectures(current_user)
    end
  end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the code above I edited the index function. I first created a conditional to check if the user is signed in and if the user is signed in to use a lambda function current_user to check the current user. These relationships would not be possible if I could lectures did not belong to user, a nested attribute. See code snippet below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Lecture &amp;lt; ApplicationRecord
    has_many :attendances, dependent: :destroy, foreign_key: :lectures_id
    belongs_to :user
    validates :name, presence: true
    scope :teachers_lectures, -&amp;gt; (user) { where(user_id: user.id) }
    accepts_nested_attributes_for :attendances
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creating different Roles&lt;/p&gt;

&lt;p&gt;If your app consist of utilizing multiple user types, chance are you are going to want to assign them different roles to allow and restrict access to certain functions. I only decided to give teachers access to this attendance app and have them log students into the portal. I assigned my users the role teacher and admin using the attribute enum. enum is an attribute where the values map to integers in the database and can be queried by name. See code snippet below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class User &amp;lt; ApplicationRecord
  enum role: {Teacher: 0, Admin: 1}
  has_many :students

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  accepts_nested_attributes_for :students
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable, :omniauthable, omniauth_providers: [:google_oauth2]


  def self.from_omniauth(auth)
    where(email: auth.info.email).first_or_initialize do |user|
      user.email = auth.info.email
      user.password = user.password_confirmation = SecureRandom.hex
    end

  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I decided to deploy my app to Heroku and if you would like to deploy your app to Heroku please feel free to check out some documentation /&lt;a href="https://devcenter.heroku.com/articles/getting-started-with-ruby"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can view my app live /&lt;a href="https://rails-attendy-webapp.herokuapp.com/"&gt;here!&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sintatra (Ruby)</title>
      <dc:creator>Szechuan SaaS</dc:creator>
      <pubDate>Mon, 12 Apr 2021 14:29:16 +0000</pubDate>
      <link>https://dev.to/swesharif27/sintatra-project-a1c</link>
      <guid>https://dev.to/swesharif27/sintatra-project-a1c</guid>
      <description>&lt;p&gt;I have completed a Sinatra project with Ruby. It's important to note that Sinatra is just a gem. It's a library of code that developers wrote to allow us to build lightweight web applications quickly.&lt;/p&gt;

&lt;p&gt;Web applications, even simple Sinatra ones, tend to require a certain degree of complexity. For example, your application might have multiple routes, route-handlers, and configurations. To handle this, Sinatra is more commonly used through the Modular Sinatra Pattern (over the classical, single-file app.RB pattern). &lt;/p&gt;

&lt;p&gt;In my experience writing endpoints in Sinatra, it took me some time to understand how the views interacted with the controllers and models. I was used to writing SQL and very complex queries however I did not anticipate the complexity of MVC. Breaking my idea down into the simplest example also helped as well building a basic CRUD web application. I'm looking to expand on what I have built thus far with rails. After completing this project I learned that I also should spend more time learning about sessions and params.&lt;/p&gt;

&lt;p&gt;Here's a link to my attendance Sinatra project below if you would like to check it out:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Sharifdesigns22/Sinatra/tree/master"&gt;https://github.com/Sharifdesigns22/Sinatra/tree/master&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Building a Fintech RubyCLI, examining the financial health of a publicly-traded stock.</title>
      <dc:creator>Szechuan SaaS</dc:creator>
      <pubDate>Mon, 08 Feb 2021 01:32:23 +0000</pubDate>
      <link>https://dev.to/swesharif27/learned-lessons-on-building-a-rubycli-339m</link>
      <guid>https://dev.to/swesharif27/learned-lessons-on-building-a-rubycli-339m</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bPDrnUmj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u3bzbgfdjg225kt110yd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bPDrnUmj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/u3bzbgfdjg225kt110yd.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I added a lot of complexity to my first Ruby CLI project. It is a CLI called &lt;em&gt;medit&lt;/em&gt; that takes in the symbol and fiscal year for stocks and returns the solvency, liquidity, Operating Margin (past 12 mo), and Profit margin aka "The four pillars" of a company's financial health. In retrospect, I would dilute it more if it saved me the headache of thinking of the deadline instead of thinking more of the concepts involved with the project. My cohort lead definitely warned me but I was passionate and determined to build this idea. Here is my advice to myself if I could go back in time: &lt;/p&gt;

&lt;p&gt;1.) If you’re looking for the best understandings of the concepts learned in the labs the best method to set you up for success for the CLI project is to start the project early and look for APIs as soon as you get to the work with APIs lab. The startup that I’m working on during the week is occupying the majority of my time and I learned, even more, the value of planning a schedule for the components that you will have to build/test in your project. It definitely helped in completing this project!&lt;/p&gt;

&lt;p&gt;2.) Make sure you connect with your cohort lead on ANY gaps of the understanding you might have and pair program as much as possible if you don’t understand even the fundamentals like how to read the API documentation for the API of choice. This gives you the creative space to build with efficient code and I just want to stress again you are not alone! You should work at your own pace but don’t let that affect your ability to complete the project and meet the deadline.&lt;/p&gt;

&lt;p&gt;The change of pace of the labs really surprised me and I didn’t have that same instant gratification of running the test using &lt;code&gt;learn —f-f&lt;/code&gt;, the CLI definitely challenged me to know relationships between classes, knowing what hashes to iterate on, and how to access variables within the raw API and was intimidating to look at a blank editor at first. I was able to overcome this paralyzed feeling by flowcharting first &lt;br&gt;
(3.) I recommend NOT to spend a lot of time and if you are you need to simplify your idea to meet the deadline of your project) and writing decent pseudocode.&lt;/p&gt;

&lt;p&gt;To highlight some small wins, what I did do right was: &lt;br&gt;
1.) Re-read through the previous labs for areas in Ruby I was struggling with &lt;br&gt;
2.) watch youtube videos on best practices for getting my bundler setup as well as research how to use case statements vs if/else statements&lt;/p&gt;

&lt;p&gt;3.) Connect with my cohort instructor and other students for working through problems whenever I got stuck. Also to google, google, and more google errors to work my way backward figuring out problems.&lt;/p&gt;

&lt;p&gt;4.) Thoroughly read through API documentation so that I understand the parameters that I am passing in&lt;br&gt;
5.) Took notes on what I will still improve on. &lt;/p&gt;

&lt;p&gt;I'm happy with what I was able to deliver and I like to think of my CLI as a tool. I'm really looking forward to building endpoints in Ruby next! &lt;/p&gt;

</description>
      <category>fintech</category>
      <category>stocks</category>
      <category>trading</category>
    </item>
  </channel>
</rss>
