<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sam Jomaiv on Medium]]></title>
        <description><![CDATA[Stories by Sam Jomaiv on Medium]]></description>
        <link>https://medium.com/@sam-j?source=rss-e606b181960------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7-hAV1zzvCIGzHQ6Oqv-LA.jpeg</url>
            <title>Stories by Sam Jomaiv on Medium</title>
            <link>https://medium.com/@sam-j?source=rss-e606b181960------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:18:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sam-j/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Attract Higher-Value Brand Sponsorships on YouTube]]></title>
            <link>https://sam-j.medium.com/how-to-attract-higher-value-brand-sponsorships-on-youtube-cc7557045f71?source=rss-e606b181960------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc7557045f71</guid>
            <category><![CDATA[brand2amplify]]></category>
            <category><![CDATA[creator-economy]]></category>
            <category><![CDATA[influencer-marketing]]></category>
            <category><![CDATA[digital-marketing]]></category>
            <category><![CDATA[youtube]]></category>
            <dc:creator><![CDATA[Sam Jomaiv]]></dc:creator>
            <pubDate>Tue, 01 Dec 2026 07:19:54 GMT</pubDate>
            <atom:updated>2026-12-01T07:41:17.619Z</atom:updated>
            <content:encoded><![CDATA[<p><em>What brands really look for in creators, and why having more subscribers isn’t always the answer.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yoiNp3No5aXX050B" /><figcaption>Photo by <a href="https://unsplash.com/@jesuslovesaustin?utm_source=medium&amp;utm_medium=referral">Jesus Loves Austin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>One of the biggest misconceptions among YouTube creators is that they need a massive following before they can start attracting well-paying brand sponsorships.</p><p>It’s understandable. When you see creators with millions of subscribers working with recognizable brands, it’s easy to assume that sponsorship opportunities are primarily driven by audience size.</p><p>Imagine two YouTube creators. One has 250,000 subscribers and publishes general entertainment content. The other has 35,000 subscribers and creates detailed technology reviews for professionals looking to make purchasing decisions.</p><p>For a software company trying to acquire new customers, the second creator could be the more valuable partner.</p><p>Why? Because reaching the right people can be far more valuable than simply reaching more people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MWu-7FoIiw7UCGNEicwFxw.png" /></figure><p>The Interactive Advertising Bureau put U.S. creator ad spending at $29.5 billion in 2024, projected $37 billion for 2025, and forecast about $44 billion for 2026. Those figures cover creator advertising across platforms.</p><h3>1. Understand Your Value From a Brand’s Perspective</h3><p>Creators and brands often look at sponsorships differently.</p><p>A creator might be thinking about how much time it takes to produce a video, how many subscribers they have, or what another creator charges for a similar integration.</p><p>A marketing manager, on the other hand, is thinking about whether the campaign will justify the investment.</p><p>Will it introduce the product to potential customers? Will people visit the company’s website? Will it generate sales? Will it help build awareness in a market the company is trying to enter?</p><p>Not every campaign is designed to generate immediate sales. Some companies are more interested in awareness, while others are focused on acquiring customers.</p><p>Understanding what a brand wants to achieve gives you a much stronger starting point for a sponsorship conversation.</p><p>It also changes how you present yourself. Instead of simply offering advertising space on your channel, you can demonstrate why your audience is relevant to the company’s objectives.</p><h3>2. Get to Know the People Behind Your Views</h3><p>If a brand asked you to describe your audience beyond their age and gender, what would you say?</p><p>What are they interested in? What problems are they trying to solve? What products do they spend money on? Why do they keep coming back to your channel?</p><p>A travel creator whose audience frequently books international flights might be an excellent fit for travel insurance providers, luggage companies, or travel credit cards.</p><p>The more you understand your audience, the easier it becomes to identify companies that have a genuine reason to work with you.</p><p>Start with the information already available in YouTube Analytics in YouTube Studio:</p><ul><li>Audience age and geographic distribution</li><li>New, casual, and regular viewers</li><li>Monthly audience size</li><li>Average video views</li><li>Other content your audience watches</li></ul><p>You can also learn a surprising amount by reading your comments. Pay attention to the questions people ask, the products they mention, and the problems they repeatedly bring up.</p><p>YouTube’s <a href="https://support.google.com/youtube/answer/9314416">guide to understanding your audience</a> is a useful resource for getting started.</p><h3>3. Don’t Let Your Subscriber Count Define Your Worth</h3><p>Subscriber count is probably the most visible measurement of a YouTube channel, but it doesn’t necessarily tell the whole story.</p><p>Consider a channel with 100,000 subscribers that currently averages 8,000 views per video, compared with a channel with 40,000 subscribers consistently generating 25,000 views.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9SPsuEFEAo8qOwNT1DOARQ.png" /></figure><p>Depending on the campaign, the smaller channel might offer better value.</p><p>Brands want to understand what kind of exposure they can realistically expect. A video that went viral two years ago may be impressive, but it isn’t necessarily a reliable indicator of future performance.</p><p>When preparing for sponsorship discussions, I recommend looking at your last 10 to 15 comparable videos and evaluating their performance.</p><p>Exclude unusual viral outliers when calculating typical reach, or at least explain them separately. Compare videos over similar time periods so that a video published last week isn’t unfairly compared with one that’s been online for six months.</p><p>Audience retention is another important consideration. If viewers regularly leave shortly after a sponsorship segment begins, that could indicate the integration needs improvement.</p><p>YouTube’s <a href="https://support.google.com/youtube/answer/9314415">audience retention reports</a> allow creators to examine how viewers engage with different parts of their videos.</p><h3>4. Make It Easy for Brands to Work With You</h3><p>A marketing manager researching dozens of creators may not have time to search through multiple social media profiles just to find a business email address.</p><p>Make sure your contact information is easy to find and that you have a professional media kit ready to share.</p><p>Your media kit doesn’t need to be a beautifully designed 20-page presentation. A concise, well-organized document with relevant information is often more useful.</p><p>Include your audience demographics, average views, content niche, social media presence, and examples of previous collaborations, if you have them.</p><p>YouTube also offers eligible creators access to media kit and brand partnership features through <a href="https://support.google.com/youtube/answer/9385307">YouTube Creator Partnerships</a>.</p><h3>5. Give Brands a Reason to Spend More</h3><p>A common approach to sponsorships is to offer a 60-second integration at a fixed price.</p><p>There’s nothing wrong with that. But if it’s the only thing you’re offering, you may be overlooking other opportunities.</p><p>Imagine you’re a productivity creator working with a project management software company.</p><p>You could spend 60 seconds explaining the product and directing viewers to a link in the description.</p><p>Alternatively, you could create an entire video showing how freelancers can organize their projects, manage deadlines, and communicate with clients using that software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gy1A6r-PT1nIw_HPnNXcwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xDz1yNX8hMurIlbKPxXt-w.png" /><figcaption>Creator reputation (58%) and audience alignment (56%) led the selection criteria. Finding the right creators was the most frequently cited top-three challenge (32%). Source: IAB and Advertiser Perceptions, 2025, pp. 13 and 15.</figcaption></figure><p>The second approach gives the product a meaningful role in the content. Viewers can see how it works in a situation they recognize, rather than simply hearing an advertisement.</p><p>It may also give the brand a piece of content that continues attracting relevant viewers through YouTube search long after publication.</p><p>A single brand relationship could potentially include a dedicated tutorial, multiple video integrations, social media content, or an ongoing educational series.</p><h3>6. Understand What You’re Giving Away When Negotiating</h3><p>Sponsorship pricing can become complicated because not every deal involves the same responsibilities or rights.</p><p>For example, a company might offer you $2,000 for a sponsored video. At first glance, that might sound reasonable.</p><p>But what if the agreement also gives the company permission to use your video in paid advertising for a year? What if you’re prohibited from working with competing brands for six months?</p><p>Suddenly, you’re offering considerably more than a single YouTube integration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqWWYod3kXe86BNV7mIHsg.png" /></figure><p>Before agreeing to a sponsorship, pay particular attention to:</p><ul><li>Content deliverables and revision requirements</li><li>Usage rights and licensing duration</li><li>Paid advertising permissions</li><li>Exclusivity agreements</li><li>Payment terms</li></ul><p>Google Ads, for example, offers <a href="https://support.google.com/google-ads/answer/15223349">Creator Partnerships Boost</a>, which allows advertisers to promote creator videos through paid campaigns when appropriate access has been granted.</p><p>There’s no universal sponsorship rate that works for every creator. Your pricing should reflect your audience, production effort, expected reach, and the commercial rights included in the agreement.</p><h3>7. Reach Out to Brands Before They Reach Out to You</h3><p>Many creators spend months waiting for sponsorship inquiries without considering that some of their best potential partners may not even know their channels exist.</p><p>Start by identifying companies whose products genuinely fit your content. Look at the brands sponsoring other creators in your niche. Pay attention to companies launching new products or entering new markets.</p><p>A generic email introducing your channel and asking whether a company is interested in sponsorships is unlikely to stand out.</p><p>A thoughtful message explaining how a specific product could fit into an upcoming video gives the recipient something tangible to consider.</p><p>Keep your initial outreach short. Introduce yourself, explain the connection between your audience and the brand, and offer to share additional information.</p><h3>8. Turn One Successful Sponsorship Into a Long-Term Relationship</h3><p>Finding new sponsors every month can be exhausting, especially when you’re also responsible for filming, editing, publishing, and managing your community.</p><p>Long-term partnerships can make the business side of content creation more predictable.</p><p>After completing a sponsored campaign, don’t disappear once the video is published and the invoice is paid.</p><p>Follow up with the brand. Share the available performance data, discuss audience feedback, and ask how the campaign performed from their perspective.</p><p>Where possible, report relevant metrics such as views, watch time, link clicks, or conversions if the brand has provided access to that information.</p><p>A recurring partnership with a well-aligned brand can be more valuable than constantly chasing higher-paying, one-off sponsorships.</p><h3>9. Never Compromise the Trust You’ve Built</h3><p>There will be times when a company offers you a good amount of money to promote something that doesn’t quite fit your audience.</p><p>If your viewers have spent years relying on your recommendations, promoting a questionable or irrelevant product could damage that relationship.</p><p>It’s also important to be transparent about paid partnerships.</p><p>The Federal Trade Commission’s <a href="https://www.ftc.gov/business-guidance/resources/disclosures-101-social-media-influencers">Disclosures 101 for Social Media Influencers</a> explains how creators should communicate their commercial relationships to audiences. For video endorsements, sponsorship disclosures should appear within the video itself, rather than solely in its description.</p><h3>Bridging the Gap Between Brands and Creators</h3><p>Finding the right brand partnership isn’t always straightforward. Creators often struggle to identify relevant sponsors, negotiate fair compensation, and manage commercial relationships. At the same time, brands face the challenge of finding creators who genuinely connect with their target customers.</p><p>At Brand2Amplify, we focus on bringing brands and creators together through thoughtful, data-driven partnerships. Our approach goes beyond subscriber counts and surface-level engagement metrics. We look at audience demographics, content relevance, brand compatibility, and the potential for long-term commercial value.</p><p>For creators, our goal is to help identify relevant sponsorship opportunities, communicate their commercial value, negotiate fair partnerships, and allow them to spend more time doing what they do best — creating content.</p><p>For brands, we focus on identifying relevant creators, developing effective campaign strategies, and establishing partnerships that align with their marketing objectives.</p><p>If you’re a creator looking to develop your sponsorship strategy or a brand exploring influencer marketing opportunities, I’d welcome the conversation.</p><p>Learn more at <a href="https://b2amplify.com/">b2amplify.com</a>.</p><h3>Final Thoughts</h3><p>Sometimes the bigger opportunity lies in better understanding the audience you already have, improving how you present your value, and finding companies that genuinely benefit from working with you.</p><p>If your content can help a company reach the right people while continuing to provide something useful to your viewers, you have the foundation for a valuable business relationship.</p><h3>About the Author</h3><p><strong>Sam Jomaiv, Founder of Brand2Amplify</strong></p><p>Sam Jomaiv is the founder of Brand2Amplify, an influencer marketing and creator partnerships agency focused on connecting brands with relevant content creators through strategic, audience-driven collaborations.</p><p>His work focuses on influencer marketing strategy, creator monetization, brand positioning, sponsorship development, and sustainable commercial partnerships.</p><h3>References and Further Reading</h3><ol><li>YouTube — <a href="https://support.google.com/youtube/answer/9314416">Understand Your YouTube Audience</a></li><li>YouTube — <a href="https://support.google.com/youtube/answer/9314415">Measure Key Moments for Audience Retention</a></li><li>YouTube — <a href="https://support.google.com/youtube/answer/9385307">Getting Started With YouTube Creator Partnerships</a></li><li>Google Ads — <a href="https://support.google.com/google-ads/answer/15471603">About YouTube Creator Partnerships</a></li><li>Google Ads — <a href="https://support.google.com/google-ads/answer/15223349">Creator Partnerships Boost</a></li><li>Federal Trade Commission — <a href="https://www.ftc.gov/business-guidance/resources/disclosures-101-social-media-influencers">Disclosures 101 for Social Media Influencers</a></li><li>IAB — <a href="https://www.iab.com/insights/2025-Creator-economy-ad-spend-strategy-report/">2025 Creator Economy Ad Spend &amp; Strategy Report</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc7557045f71" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Search…]]></title>
            <link>https://sam-j.medium.com/search-7772403b90c9?source=rss-e606b181960------2</link>
            <guid isPermaLink="false">https://medium.com/p/7772403b90c9</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[search-engine-optimizati]]></category>
            <category><![CDATA[search]]></category>
            <dc:creator><![CDATA[Sam Jomaiv]]></dc:creator>
            <pubDate>Thu, 30 Sep 2021 07:55:29 GMT</pubDate>
            <atom:updated>2026-11-11T15:29:50.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*CfnoxQ0C9iU9yXp491wyNQ.png" /></figure><p>So you want to add a Searchbar to your component but don’t know where to start?</p><p>In this blog, I will give a basic explanation about adding a Search feature to your component using React.js.</p><p>The search bar is the location within the app that allows you to search the data for what you want to find. In the example of a “Plant Shop” website the search bar allows to search for words(string), numbers(integer), and symbols that exist in the database and returns the desired results. Not to be confused with search engines, search bars are relatively straightforward, and with that in mind let’s start building one for our “Plant Shop”.</p><p>Our Plant Shop has the following structure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1YkbWebjcXhMP9jk-6HvoA.png" /></figure><p>Now that you have an idea of how the file structure looks like, you can start building those components. In this blog, I won’t be showing everything step-by-step, but I will show all the necessary code you need to add a search feature to your React app.</p><p>The code below shows how our App.js looks like. Pretty Simple!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rSYADrVWxOIxiQMMAJSEcw.png" /></figure><p>Since we won’t need the search bar anywhere else, we can fetch the data we need from our database in the PlantsPage component, which is where we will nest our Search Component.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SY67pUqOg3kLLI_b505APw.png" /></figure><p>As you can see in the code above we are inside “PlantPage” component where we are going to initialize our state(hook) “plants”, and “SearchTerm” to be an empty array where we will store our fetched data, and use them where we need. After fetching we will set the plants state to be plants data we are fetching from the database. Now our state holds the “plants” array!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jrG3JLLEk01j-ziB7YogmA.png" /></figure><p>The key moment: We filter the state and give a constant of displayedPlants which will create individual objects“plant” array data then we return only the names of the plants we tell the function to include which is stored in “SearchTerm” (currently an empty array). Also, we added “.<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase">toLowerCase</a>()” which is a function that returns the result irrespective of their case sensitivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jkIQkVyDfSrEulb3yCWKXQ.png" /></figure><p>Then in the JSX we will return and send “searchTerm”. We will send it as a prop to a newly created component “Search” along with onSearchChange which is a function to change the state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QH0UQ21sJ1-H_CIKBsRrw.png" /></figure><p>In the search component, we will receive the props (searchTerm, onSearchChange) and return the search bar in the JSX with the text placeholder “Search Plants…”.</p><p><strong>value={searchTerm}</strong></p><p>In the &lt;Input&gt; we set the value to be our SearchTem state so when we type something it gets stored there and check if it includes(.<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes">includes</a>(SearchTerm.toLowerCase() ).</p><p><strong>onChange={(e) =&gt; onSearchChange(e.target.value)}</strong></p><p>One important thing to note is “onChange” is used to handle user input in real-time. It means that whatever value we type in the search bar, it will be rendered to the page which is the result of the search!</p><p>This was a basic example of implementing a Search feature for a web app. For more info, you can refer to the GitHub repo link:<a href="https://github.com/SamJoma/react-hooks-mock-code-challenge-plantshop.git">https://github.com/SamJoma/react-hooks-mock-code-challenge-plantshop.git</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7772403b90c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Login and Authenticate in Rails]]></title>
            <link>https://sam-j.medium.com/login-and-authenticate-in-rails-d1127d52a268?source=rss-e606b181960------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1127d52a268</guid>
            <category><![CDATA[authenticated-encryption]]></category>
            <category><![CDATA[session-cookie]]></category>
            <category><![CDATA[login-page]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Sam Jomaiv]]></dc:creator>
            <pubDate>Thu, 16 Sep 2021 19:17:05 GMT</pubDate>
            <atom:updated>2021-09-24T18:44:11.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*Q44a8mlA7CdsAVGK_DBPWQ.png" /></figure><p>Have you ever wondered what happens under the hood of a website when you log in to your account? Well in this lesson I will explain that in detail:</p><p>🔑 How a log-in page is created</p><p>🔑 How it authenticates and logs in users</p><p>🔑 How to log-out of a session</p><p>In order to create a Login Page, we will use React.js (Fron-End) and Ruby on Rails(back-end)</p><p>When we create a rails app, we need to create our models using the “rails generator” command:</p><blockquote>rails g resource model_name column_name:integer column_name:string</blockquote><p>(you need to run this command for each model)</p><p><strong>It generates the following:</strong></p><p><em>•Routes</em></p><p><em>•Models</em></p><p><em>•Controllers</em></p><p><em>•Serializers for our Models</em></p><p><em>•Migrations(you need to seed some data)</em></p><p>These are the main things we need to create a Rails app and Now let’s write some code inside our Controllers which is where we write our logic.</p><p><strong>Authenticate</strong></p><p><em>What is authentication?</em></p><p>User authentication is a process in which you verify that someone who is attempting to access services and applications is who they claim to be. This can be accomplished through a variety of authentication methods, such as entering a password into your laptop or phone or a PIN number into the ATM.</p><p>We are going to create a “Sessions” controller (which is not created with “<em>ralis g resource” command</em>) and the command for that is:</p><blockquote><em>rails generate scaffold_controller Sessions</em></blockquote><p>It will generate all the necessary components including the route.</p><p>post &quot;/login&quot;, to: &quot;sessions#create&quot;</p><p>As you can see we routed the login page to: sessions#create (session controller and create action)</p><p>Here is the Sessions Controller with #create action written inside of it:</p><pre>class SessionsController &lt; ApplicationController<br>  def create<br>    user = User.find_by(username: params[:username])<br>    session[:user_id] = user.id<br>    render json: user<br>  end<br>end</pre><p>Let me break it down for you…</p><p>In the “create action” of the SessionsController we set a cookie on the user&#39;s browser by writing their user ID into the session hash.</p><pre>user = User.find_by(username: params[:username])</pre><p>Inside our create action method (def create) Rails is looking for the user to see if it exists in the database which is where our username and password are saved and stored securely.</p><pre>session[:user_id] = user.id</pre><p>If the user exists, it will log in, a cookie on the user’s browser will be set by writing their user ID into the session. Thereafter session[:user_id] will hold their user ID. This is how we get authenticated!</p><p>Now our backend and Front-end know who we are(assuming you have a front end) but what happens when we refresh the page? unfortunately, we get logged out of our session. Here is how to make sure we stay logged in: we need a route to retrieve the user’s data from the database using the session hash:</p><pre>get &quot;/me&quot;, to: &quot;users#show&quot;</pre><p>Now we need to create a new Controller, “UsersController”.</p><pre>class UsersController &lt; ApplicationController<br>  def show<br>    user = User.find_by(id: session[:user_id])<br>    if user<br>      render json: user<br>    else<br>      render json: { error: &quot;Not authorized&quot; }, status: :unauthorized<br>    end<br>  end<br>end</pre><p>In “UsersController”, as you can see, we have a #show action which will be used to keep us signed in. Here is some example of how your Front_End might look like:</p><pre>function App() {<br>  const [user, setUser] = useState(null);</pre><pre>  useEffect(() =&gt; {<br>    fetch(&quot;/me&quot;).then((response) =&gt; {<br>      if (response.ok) {<br>        response.json().then((user) =&gt; setUser(user));<br>      }<br>    });<br>  }, []);</pre><pre>  if (user) {<br>    return &lt;h2&gt;Welcome, {user.username}!&lt;/h2&gt;;<br>  } else {<br>    return &lt;Login onLogin={setUser} /&gt;;<br>  }<br>}</pre><p>We are fetching from (&quot;/me&quot;)and saying if the response is ok, set our current state to “user” (which is a “useState()” hook)</p><pre>if (user) {<br>    return &lt;h2&gt;Welcome, {user.username}!&lt;/h2&gt;;<br>  } else {<br>    return &lt;Login onLogin={setUser} /&gt;;<br>  }<br>}</pre><p>Then we use conditional statements to render our user to the Front-End. Basically, the code above is saying if user is true (meaning it exists in our database) then show us Welcome text along with the user’s username. Otherwise, if the user is not in our database, send the user to the Login page.</p><p>What if want to log out? This is one is easy! We can simply delete the session hash which will log us out. Here is how we do it:</p><pre>delete &quot;/logout&quot;, to: &quot;sessions#destroy&quot;</pre><p>Create a route for Logout in the SessionController with #destroy action.</p><pre>class SessionsController &lt; ApplicationController</pre><pre>def destroy<br>  session.delete :user_id<br>  head :no_content<br>end</pre><p>What “destroy” method does is, that it will delete the stored user_id in the session hash which will result in the user being logged out of the page.</p><p><strong>Conclusion</strong></p><p>That’s it, you know how a log-in and log-out feature works in Rails using REST API. To recap login is very simple: the user provides you with credentials in the login form, the database verifies if a given user’s credentials exist in the database(back-end) and our front end will log us in with an appropriate message and data from the database. In order to stay logged in in the front-end, we create a session hash that will store our user_id. If we wanted to log out of that session we can simply delete that hash and we are out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1127d52a268" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[#Sorting in Ruby]]></title>
            <link>https://sam-j.medium.com/sorting-in-ruby-663c1dd482b7?source=rss-e606b181960------2</link>
            <guid isPermaLink="false">https://medium.com/p/663c1dd482b7</guid>
            <category><![CDATA[sorting]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Sam Jomaiv]]></dc:creator>
            <pubDate>Fri, 13 Aug 2021 17:52:59 GMT</pubDate>
            <atom:updated>2021-08-13T17:54:37.980Z</atom:updated>
            <content:encoded><![CDATA[<p>Sorting in Ruby isn&#39;t too complicated as you might think, but there are different ways of doing it. In this blog I will talk about sorting in Ruby. But before let me explain what sorting is why is it important.</p><p>In computer science, a sorting algorithm is an algorithm that puts elements of a list into an order. The most frequently used orders are numerical order and lexicographical order, and either ascending or descending. Efficient sorting is important for optimizing the efficiency of other algorithms (such as search and merge algorithms) that require input data to be in sorted lists.</p><p>Sorting is an important aspect of any business that affects sales. A poor sorting functionality on a website could lead to losses for a particular business. If customers of a website can’t easily find what they are looking for (for example if a customer cannot view products by category or price) that could drive people off your platform. So now that we know how sorting is important, let’s take a look under the hood how these sorting functionalities work, particularly in Ruby.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CezvPxMiInfkWx7b8MkkQ.jpeg" /></figure><p>Ruby’s #sort method can be called a couple different ways. If you have a simple array of strings or numbers, for example, you can call #sort without a block, and Ruby will do its best to sort the elements:</p><pre>nums = [1, 5, 3]<br>sorted_nums = nums.sort<br>sorted_nums<br># =&gt; [1, 3, 5]</pre><p>Note that in some languages like JavaScript, #sort will alter the original array. But in Ruby #sort does not alter the original array.</p><p>When sorting more complex data, you can also provide a block and write a sorting algorithm of your own. The block must return either -1, 0, or 1 to determine the sort order. This can result in some not-so-pleasant code:</p><pre>users = [<br>  { name: &quot;Liza&quot;, phone: &quot;555-555-5556&quot; },<br>  { name: &quot;Duane&quot;, phone: &quot;555-555-5555&quot;},<br>  { name: &quot;Cara&quot;, phone: &quot;555-555-5556&quot;},<br>]</pre><pre>sorted_users = users.sort do |user1, user2|<br>  if user1[:name] == user2[:name]<br>    0<br>  elsif user1[:name] &lt; user2[:name]<br>    -1<br>  elsif user1[:name] &gt; user2[:name]<br>    1<br>  end<br>end</pre><pre>sorted_users<br># =&gt; [{:name=&gt;&quot;Cara&quot;, :phone=&gt;&quot;555-555-5556&quot;}, {:name=&gt;&quot;Duane&quot;, :phone=&gt;&quot;555-555-5555&quot;}, {:name=&gt;...</pre><p>We can simplify the code above a bit by using the “spaceship operator” (&lt;=&gt;). The spaceship operator, also called the <strong>combined comparison operator</strong>, returns:</p><ul><li>0 if the first operand equals the second,</li><li>-1 if the first operand is less than the second, and</li><li>1 if the first operand is greater than the second.</li></ul><p>So, instead of utilizing if and elsif logic like we did above, we can simply call #sort with the following code:</p><pre>users.sort do |user1, user2|<br>  user1[:name] &lt;=&gt; user2[:name]<br>end<br># =&gt; [{:name=&gt;&quot;Cara&quot;, :phone=&gt;&quot;555-555-5556&quot;}, {:name=&gt;&quot;Duane&quot;, :phone=&gt;&quot;555-555-5555&quot;}, {:name=&gt;...</pre><p>Ruby also provides a #sort_by method, which, instead of passing two elements to the block and requiring you to write the comparison logic, just passes one element to the block:</p><pre>users.sort_by do |user1|<br>  user1[:name]<br>end<br># =&gt; [{:name=&gt;&quot;Cara&quot;, :phone=&gt;&quot;555-555-5556&quot;}, {:name=&gt;&quot;Duane&quot;, :phone=&gt;&quot;555-555-5555&quot;}, {:name=&gt;...</pre><p>So now I hope that you have some idea on how sorting functionalities work in Ruby, as you see in examples above, Ruby makes sorting enjoyable, unlike JavaScript, the code looks a lot cleaner and more understandable which makes our life a lot easier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=663c1dd482b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Component Structure]]></title>
            <link>https://sam-j.medium.com/react-component-structure-d38d59eefffd?source=rss-e606b181960------2</link>
            <guid isPermaLink="false">https://medium.com/p/d38d59eefffd</guid>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[react-components]]></category>
            <category><![CDATA[javascript-vs-typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Sam Jomaiv]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 05:01:24 GMT</pubDate>
            <atom:updated>2026-11-11T05:10:31.185Z</atom:updated>
            <content:encoded><![CDATA[<p>Components let you break a user interface into independent, reusable pieces and think about each piece on its own. In this post, I’ll cover the basics of React components. First, let’s look at what React is.</p><p>React (also known as React.js or ReactJS) is a free, open-source JavaScript library for building user interfaces. It was created by Jordan Walke, an engineer at Facebook. Developers use React to build web applications and can use React Native to build mobile apps. React provides tools for managing component state and updating the UI when data changes. Depending on the application, you might use other libraries or a framework for features like routing.</p><p><strong>What are React components, and how do they compare with vanilla JavaScript?</strong></p><p>A React component is a reusable piece of the UI, such as a search bar, restaurant card, or shopping cart. You can build reusable UI pieces with vanilla JavaScript, too. React gives you a consistent way to define them, pass data to them, and describe what they should display as that data changes.</p><p>In the image below, the red labels identify components on a food delivery website. Breaking the site into components lets you work on one part at a time. For example, you could define a restaurant card once and reuse it for every restaurant on the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmRD7YIgQsWEt8PBa1dIyQ.png" /></figure><p>App.js almost always represents the entire application and in our example above it has 3 nested components in addition to that, its components have nested components too!</p><p><strong>Here is a plain tree of our App for better visualization of what we are working with:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FmLsMz6_YG_3hUFNfaNzTQ.png" /></figure><p>It looks good in a tree but how does it look in the code?</p><p><strong>This is how it looks in the Code editor:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SMAem-lYZUE1sWCy92W1wg.png" /></figure><p>As you have noticed we have multiple .js(for example App.js, Map.js) files in the components folder on the left. They represent all of our app’s components. Each component is nothing but a set of functions that return something.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lFNMygrDbNZ8r8_CBNb67w.png" /></figure><p><strong>How does React structure compare to Vanilla JavaScript ?</strong></p><p>The best way to understand how React works is by comparing it to plain JS. A plain JS works without any libraries. Basically, JavaScript is a scripting language and it does not give in to any rules.</p><p>However, in React, how the data flow has clearly defined rules. React apps have a structure. Each piece of code that performs on its own is constrained inside a component. These components work in isolation but communicate with each other to make the web application work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*20kvGS5lJviwKHvltV7EEw.png" /></figure><p>In the image example above you can see we only have 1 component which ends with “.js” (index.js) that’s standard in JavaScript to use single file to write all of our code in, which can be challenging when we are working with big applications, hence using React simplifies and organizes the file structure and its library helps us write modern applications faster and more efficiently.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d38d59eefffd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>