<?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 Rıza Doğukan Koşar on Medium]]></title>
        <description><![CDATA[Stories by Rıza Doğukan Koşar on Medium]]></description>
        <link>https://medium.com/@rizadogukankosar?source=rss-483a96e54eb1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*B7kdA59YtzuZVG-PCOe-GQ@2x.jpeg</url>
            <title>Stories by Rıza Doğukan Koşar on Medium</title>
            <link>https://medium.com/@rizadogukankosar?source=rss-483a96e54eb1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:18:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rizadogukankosar/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[What is Blob & Attachment- Ruby on Rails]]></title>
            <link>https://medium.com/@rizadogukankosar/what-is-blob-attachment-ruby-on-rails-afee747b1eb8?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/afee747b1eb8</guid>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Wed, 21 Jun 2023 20:53:29 GMT</pubDate>
            <atom:updated>2023-06-21T20:53:29.722Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Is1DuQjH0uoxyzN0ZUdZaQ.jpeg" /></figure><p>Ruby on Rails is a framework that utilizes the concepts of Blob and Attachment to manage user file uploads. While Blob represents a data type that generally represents a large amount of data, such as text or images, Attachment represents a file or media attached to an object.</p><p><strong>Blob: </strong>Blob, short for Binary Large Object, is commonly used to represent a large amount of data, such as text or images. Ruby on Rails uses the Active Storage library to store and manage Blob objects in the database. This library provides a set of conveniences for uploading, storing, and retrieving Blob data. For example, you can use Blob to upload profile pictures for users. The profile picture is stored as a Blob and can be served as an image when requested.</p><p><strong>Attachment:</strong> Attachment represents a file or media attached to an object. For instance, consider wanting to add an image to a blog post. This image would be referred to as an Attachment. Ruby on Rails’ Active Storage library allows you to easily handle such attachments. Active Storage enables features such as caching files, adding drag and drop functionality, automatically resizing image dimensions, and more.</p><p>Let’s consider an example scenario where you want to allow users to add an image to a blog post. The image would be stored as a Blob and attached to the blog post object as an Attachment. This means that when viewing the post, you can retrieve the associated image through the Attachment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afee747b1eb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Counter cache- How to use in Ruby on Rails ? - Episode 5]]></title>
            <link>https://medium.com/@rizadogukankosar/counter-cache-how-to-use-in-ruby-on-rails-episode-5-5ccca6da000d?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ccca6da000d</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 19:21:01 GMT</pubDate>
            <atom:updated>2023-06-13T19:25:37.327Z</atom:updated>
            <content:encoded><![CDATA[<h3>Counter cache - How to use in Ruby on Rails ? - Episode 5</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Is1DuQjH0uoxyzN0ZUdZaQ.jpeg" /></figure><p>Counter cache in Rails is a feature that allows an associated model to cache the count of related records for a specific association. Instead of executing a separate count query on the database each time, the cached count can be quickly retrieved.</p><p>There are several advantages to using counter cache:</p><ol><li>Performance Improvement: By caching the count of associated records in a separate column, counter cache eliminates the need for separate count queries. This reduces the number of database queries and improves query performance.</li><li>Reduced Database Load: Counter cache minimizes the need for querying associated records directly, reducing the load on the database. This can be particularly beneficial when dealing with large datasets and high traffic applications.</li><li>Query Optimization: Retrieving the count of associated records quickly can optimize certain queries. For example, by retrieving the comment count of an article through counter cache, you can avoid an additional query when displaying the comment count for each article on a listing page.</li></ol><h4>Basic Usage:</h4><p><strong>Step 1:</strong></p><p>Define the Associated Models: Identify the models for which you want to enable counter cache. For example, if you have an “Article” model with several “Comment” records associated with it, you need to define the models correctly.</p><pre>class User &lt; ApplicationRecord<br>  has_many :posts<br>end<br><br>class Post &lt; ApplicationRecord<br>  belongs_to :user, counter_cache: true<br>end</pre><p><strong>Step 2:</strong></p><p>Add a Counter Cache Column to the Database: You need to add a column to store the counter cache value in the database. Rails will automatically update this column.</p><pre>class AddPostsCountToUsers &lt; ActiveRecord::Migration[6.0]<br>  def change<br>    add_column :users, :posts_count, :integer, default: 0<br>  end<br>end</pre><p>Now, you can use the counter</p><pre>user = User.last<br>=&gt; [user record]<br><br>user.posts_count # =&gt; 0<br><br>user.posts.build(title: &#39;post title&#39;).save<br>#  TRANSACTION (0.2ms)  BEGIN<br>#  Post Create (0.5ms)  INSERT INTO &quot;posts&quot; (&quot;title&quot;, &quot;body&quot;, &quot;user_id&quot;, &quot;created_at&quot;, &quot;updated_at&quot;) VALUES ($1, $2, $3, $4, $5) RETURNING &quot;id&quot;  [[&quot;title&quot;, &quot;post title&quot;], [&quot;body&quot;, nil], [&quot;user_id&quot;, 1], [&quot;created_at&quot;, &quot;2023-06-13 19:07:53.628768&quot;], [&quot;updated_at&quot;, &quot;2023-06-13 19:07:53.628768&quot;]]<br>#  User Update All (0.3ms)  UPDATE &quot;users&quot; SET &quot;posts_count&quot; = COALESCE(&quot;posts_count&quot;, 0) + $1 WHERE &quot;users&quot;.&quot;id&quot; = $2  [[&quot;posts_count&quot;, 1], [&quot;id&quot;, 1]]<br>#  TRANSACTION (1.0ms)  COMMIT<br>=&gt; true<br><br><br>user.posts_count # =&gt; 1<br><br>user.posts.last.destroy<br>#  TRANSACTION (0.2ms)  BEGIN<br>#  Post Destroy (0.4ms)  DELETE FROM &quot;posts&quot; WHERE &quot;posts&quot;.&quot;id&quot; = $1  [[&quot;id&quot;, 3]]<br>#  User Update All (0.7ms)  UPDATE &quot;users&quot; SET &quot;posts_count&quot; = COALESCE(&quot;posts_count&quot;, 0) - $1 WHERE &quot;users&quot;.&quot;id&quot; = $2  [[&quot;posts_count&quot;, 1], [&quot;id&quot;, 1]]<br>#  TRANSACTION (1.0ms)  COMMIT<br>=&gt; [post record]<br><br>user.posts_count # =&gt; 0</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ccca6da000d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serialization — How to use in Ruby on Rails ? - Episode 4]]></title>
            <link>https://medium.com/@rizadogukankosar/serialization-how-to-use-in-ruby-on-rails-episode-4-81338f7bf20d?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/81338f7bf20d</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails-developers]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Sat, 10 Jun 2023 12:05:29 GMT</pubDate>
            <atom:updated>2023-06-10T19:27:12.993Z</atom:updated>
            <content:encoded><![CDATA[<h3>Serialization — How to use in Ruby on Rails ? - Episode 4</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Is1DuQjH0uoxyzN0ZUdZaQ.jpeg" /></figure><p>ActiveModel::Serialization is a module in Ruby on Rails that allows model objects to be converted into exportable formats such as JSON or XML. This module is used to determine the exportable properties of model objects and perform the conversion process.</p><p>It can be used with ActiveRecord models and is particularly useful when creating APIs. By exporting specific properties of model objects, it enables clients to receive the data they need. For example, if you are working with a user model and want to export information such as the username and email address, you can utilize the ActiveModel::Serialization module.</p><p>ActiveModel::Serialization allows you to convert model objects into JSON format using the as_json method or into XML format using the to_xml method. These methods can be used with options to control which properties of the model you want to export.</p><h4>Usage:</h4><p><strong>1- as_json (Record to json):</strong></p><pre>user = User.find(1)<br>user.as_json<br># =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#     &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:133.000Z&quot;, &quot;awesome&quot; =&gt; true}<br><br>ActiveRecord::Base.include_root_in_json = true<br><br>user.as_json<br># =&gt; { &quot;user&quot; =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#                  &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:13.000Z&quot;, &quot;awesome&quot; =&gt; true } }</pre><blockquote>This behavior can also be achieved by setting the :root option to true as in:</blockquote><pre>user = User.find(1)<br>user.as_json(root: true)<br># =&gt; { &quot;user&quot; =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#                  &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:13.000Z&quot;, &quot;awesome&quot; =&gt; true } }</pre><blockquote>If you prefer, :root may also be set to a custom string key instead as in:</blockquote><pre>user = User.find(1)<br>user.as_json(root: &quot;author&quot;)<br># =&gt; { &quot;author&quot; =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#                  &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:13.000Z&quot;, &quot;awesome&quot; =&gt; true } }</pre><blockquote>The :only and :except options can be used to limit the attributes included, and work similar to the attributes method.</blockquote><pre>user.as_json(only: [:id, :name])<br># =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot; }</pre><pre>user.as_json(except: [:id, :created_at, :age])<br># =&gt; { &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;awesome&quot; =&gt; true }</pre><blockquote>To include the result of some method calls on the model use :methods:</blockquote><pre>user.as_json(methods: :permalink)<br># =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#      &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:13.000Z&quot;, &quot;awesome&quot; =&gt; true,<br>#      &quot;permalink&quot; =&gt; &quot;1-konata-izumi&quot; }</pre><blockquote>To include associations use :include:</blockquote><pre>user.as_json(include: :posts)<br># =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#      &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:13.000Z&quot;, &quot;awesome&quot; =&gt; true,<br>#      &quot;posts&quot; =&gt; [ { &quot;id&quot; =&gt; 1, &quot;author_id&quot; =&gt; 1, &quot;title&quot; =&gt; &quot;Welcome to the weblog&quot; },<br>#                   { &quot;id&quot; =&gt; 2, &quot;author_id&quot; =&gt; 1, &quot;title&quot; =&gt; &quot;So I was thinking&quot; } ] }</pre><blockquote>Second level and higher order associations work as well:</blockquote><pre>user.as_json(include: { posts: {<br>                           include: { comments: {<br>                                          only: :body } },<br>                           only: :title } })<br># =&gt; { &quot;id&quot; =&gt; 1, &quot;name&quot; =&gt; &quot;Konata Izumi&quot;, &quot;age&quot; =&gt; 16,<br>#      &quot;created_at&quot; =&gt; &quot;2006-08-01T17:27:13.000Z&quot;, &quot;awesome&quot; =&gt; true,<br>#      &quot;posts&quot; =&gt; [ { &quot;comments&quot; =&gt; [ { &quot;body&quot; =&gt; &quot;1st post!&quot; }, { &quot;body&quot; =&gt; &quot;Second!&quot; } ],<br>#                     &quot;title&quot; =&gt; &quot;Welcome to the weblog&quot; },<br>#                   { &quot;comments&quot; =&gt; [ { &quot;body&quot; =&gt; &quot;Don&#39;t think too hard&quot; } ],<br>#                     &quot;title&quot; =&gt; &quot;So I was thinking&quot; } ] }</pre><p><strong>2- from_json (JSON to Record):</strong></p><pre>class Person<br>  include ActiveModel::Serializers::JSON<br><br>  attr_accessor :name, :age, :awesome<br><br>  def attributes=(hash)<br>    hash.each do |key, value|<br>      send(&quot;#{key}=&quot;, value)<br>    end<br>  end<br><br>  def attributes<br>    instance_values<br>  end<br>end<br><br>json = { name: &#39;bob&#39;, age: 22, awesome:true }.to_json<br>person = Person.new<br>person.from_json(json) # =&gt; #&lt;Person:0x007fec5e7a0088 @age=22, @awesome=true, @name=&quot;bob&quot;&gt;<br>person.name            # =&gt; &quot;bob&quot;<br>person.age             # =&gt; 22<br>person.awesome         # =&gt; true</pre><blockquote>The default value for include_root is false. You can change it to true if the given <a href="https://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html">JSON</a> string includes a single root node.</blockquote><pre>json = { person: { name: &#39;bob&#39;, age: 22, awesome:true } }.to_json<br>person = Person.new<br>person.from_json(json, true) # =&gt; #&lt;Person:0x007fec5e7a0088 @age=22, @awesome=true, @name=&quot;bob&quot;&gt;<br>person.name                  # =&gt; &quot;bob&quot;<br>person.age                   # =&gt; 22<br>person.awesome               # =&gt; true</pre><h3>Referances:</h3><p><a href="https://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html">https://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81338f7bf20d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Active Record Encryption — How to use in Ruby on Rails ? — Episode 3]]></title>
            <link>https://medium.com/@rizadogukankosar/active-record-encryption-how-to-use-in-ruby-on-rails-episode-3-9807437bc4f1?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/9807437bc4f1</guid>
            <category><![CDATA[ruby-on-rails-developers]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Fri, 09 Jun 2023 20:01:39 GMT</pubDate>
            <atom:updated>2023-06-10T19:39:14.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>Active Record Encryption — How to use in Ruby on Rails ? — Episode 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Is1DuQjH0uoxyzN0ZUdZaQ.jpeg" /></figure><p>Active Record encryption in Rails is a method that ensures sensitive data stored in the database remains secure by encrypting it. Active Record is the component of Rails responsible for database operations and can encrypt and decrypt data during these operations.</p><p>Active Record encryption is commonly used to secure sensitive information such as user passwords, credit card details, social security numbers, and more. Storing such data in plaintext in the database can lead to security vulnerabilities and leave them exposed to unauthorized access.</p><p>With Active Record encryption, data is stored in an encrypted format in the database. This means that even if there is unauthorized access to the database, the encrypted data remains unintelligible. Only with the correct key can the encrypted data be decrypted and accessed in its original form. This helps ensure user privacy and data security.</p><p>There are several Ruby Gems available for Active Record encryption, providing methods and tools that simplify the encryption process. For example, the ‘attr_encrypted’ Gem allows for field-level encryption in Active Record models.</p><p>Active Record encryption is an important step in ensuring the security of sensitive data and is widely preferred for user privacy and data security in Rails applications.</p><h4><strong>Basic Usage:</strong></h4><h4>Step 1:</h4><p>First, you need to add some keys to your <a href="https://guides.rubyonrails.org/security.html#custom-credentials">Rails credentials</a>. Run bin/rails db:encryption:init to generate a random key set:</p><pre>$ bin/rails db:encryption:init<br>=&gt;<br>Add this entry to the credentials of the target environment:<br><br>active_record_encryption:<br>  primary_key: EGY8WhulUOXixybod7ZWwert38R9o5kC<br>  deterministic_key: aPA5XyALhf75NNnMzaspW7akTerg4p0lPY<br>  key_derivation_salt: xEY0dt6TZcAMg52K7O84wYzweAvbA62Hz</pre><h4>Step 2:</h4><p>Open terminal and edit credentials</p><pre>EDITOR=vim rails credentials:edit</pre><p>Now press i and add active_record_encryption keys. After this pres ESC and quit editor with write :wq</p><pre># aws:<br>#   access_key_id: 123<br>#   secret_access_key: 345<br><br># Used as the base secret for all MessageVerifiers in Rails, including the one protecting cookies.<br>active_record_encryption:<br>  primary_key: EGY8WhulUOXixybod7ZWwert38R9o5kC<br>  deterministic_key: aPA5XyALhf75NNnMzaspW7akTerg4p0lPY<br>  key_derivation_salt: xEY0dt6TZcAMg52K7O84wYzweAvbA62Hz<br>.<br>.<br>.</pre><h4>Step 3:</h4><p>add encrypts attributes in model</p><pre>class Article &lt; ApplicationRecord<br>  encrypts :title<br>end</pre><p>Now we test this on rails console:</p><pre>article = Article.create title: &quot;Encrypt it all!&quot;<br><br>=&gt; INSERT INTO `articles` (`title`) VALUES (&#39;{\&quot;p\&quot;:\&quot;n7J0/ol+a7DRMeaE\&quot;,\&quot;h\&quot;:<br>{\&quot;iv\&quot;:\&quot;DXZMDWUKfp3bg/Yu\&quot;,\&quot;at\&quot;:\&quot;X1/YjMHbHD4talgF9dt61A==\&quot;}}&#39;)<br><br><br>article.title # =&gt; &quot;Encrypt it all!&quot;</pre><h3>Referances:</h3><p><a href="https://guides.rubyonrails.org/active_record_encryption.html">Active Record Encryption - Ruby on Rails Guides</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9807437bc4f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scopes -  How to use in Ruby on Rails ? - Episode 2]]></title>
            <link>https://medium.com/@rizadogukankosar/scopes-how-to-use-in-ruby-on-rails-episode-2-df87404b0906?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/df87404b0906</guid>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby-on-rails-developers]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Fri, 09 Jun 2023 12:14:54 GMT</pubDate>
            <atom:updated>2023-06-09T12:31:35.112Z</atom:updated>
            <content:encoded><![CDATA[<h3>Scopes - How to use in Ruby on Rails ? - Episode 2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Is1DuQjH0uoxyzN0ZUdZaQ.jpeg" /></figure><p>In Ruby on Rails, “scope” is a concept used to define reusable query constraints in ActiveRecord models. Scopes allow you to apply specific filtering conditions, perform sorting, or create custom query scopes. Scopes make queries more readable and manageable by combining query constraints.</p><p>Scopes are defined within the model class using the scope method. This method is used to specify query constraints and conditions. For example:</p><pre>class Article &lt; ApplicationRecord<br>  scope :published, -&gt; { where(published: true) }<br>  scope :popular, -&gt; { where(&#39;views &gt; ?&#39;, 1000) }<br>end</pre><pre>Article.all # =&gt; SELECT * FROM articles<br><br>Article.published # =&gt; SELECT * FROM articles WHERE published = true<br><br>Article.published.popular # =&gt; SELECT * FROM articles WHERE published = true AND views &gt; 1000</pre><p><strong>Default Scope &amp; Unscoped:</strong></p><p>In Rails, “default_scope” is a feature used to define a default query scope that is automatically applied when retrieving data from the database in ActiveRecord models. It specifies the query conditions that will be applied by default instead of repeating them in every query, reducing code duplication.</p><p>Default_scope is defined within the model class using the default_scope method. This method is used to specify the query scope and conditions. For example:</p><pre>class Article &lt; ApplicationRecord<br>  default_scope { where(published: true) }<br>end</pre><pre>Article.all # =&gt; SELECT * FROM articles WHERE published = true<br>Article.unscoped.all # =&gt; SELECT * FROM articles<br>Post.where(published: false).unscoped.all # =&gt; SELECT * FROM articles</pre><p>There are some important considerations when using default_scope:</p><ul><li>Default_scope affects all queries, so it should be used with caution. Make sure that the default conditions are appropriate for all queries.</li><li>Multiple default_scope definitions are possible, but the query scopes are applied in the order they are defined. The scope of the previous definition is applied to the result.</li><li>You can disable the default query scope using the unscoped method. For example, Article.unscoped.all can be used to bypass the default query scope.</li></ul><h3>References:</h3><p><a href="https://api.rubyonrails.org/classes/ActiveRecord/Scoping.html">https://api.rubyonrails.org/classes/ActiveRecord/Scoping.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df87404b0906" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[signed_id - How to use in Ruby on Rails ? - Episode 1]]></title>
            <link>https://medium.com/@rizadogukankosar/signed-id-how-to-use-in-ruby-on-rails-episode-1-f592997f9191?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f592997f9191</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[ruby-on-rails-development]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Thu, 08 Jun 2023 14:55:00 GMT</pubDate>
            <atom:updated>2023-06-08T14:55:00.525Z</atom:updated>
            <content:encoded><![CDATA[<h3>signed_id - How to use in Ruby on Rails ? - Episode 1</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Is1DuQjH0uoxyzN0ZUdZaQ.jpeg" /></figure><p>In Ruby on Rails, the signed_id is a feature provided by the framework to sign and verify parameters or URLs. It is primarily used to prevent tampering or unauthorized access to data by generating a secure digital signature.</p><p>Lets you find a record based on a signed id that’s safe to put into the world without risk of tampering. This is particularly useful for things like password reset or email verification, where you want the bearer of the signed id to be able to interact with the underlying record, but usually only within a certain time period.</p><p>You set the time period that the signed id is valid for during generation, using the instance method signed_id(expires_in: 15.minutes). If the time has elapsed before a signed find is attempted, the signed id will no longer be valid, and nil is returned.</p><p>It’s possible to further restrict the use of a signed id with a purpose. This helps when you have a general base model, like a User, which might have signed ids for several things, like password reset or email verification. The purpose that was set during generation must match the purpose set when finding. If there’s a mismatch, nil is again returned.</p><p><strong>Basic Usage:</strong></p><pre>user = User.last<br><br># signed_id for last user<br>signed_id = user.signed_id<br>=&gt; &quot;eyJfcmFpbHMiOnsibWVzc2FnZSI6Ik9RPT0iLRLleHAiOm51bGwsInB1ciI6InVzZXIifX0=--8bf2b4c859658653ce52cc16ef980g2ab5c292945d518c07bc05519d89811871&quot;<br><br># Find user with signed_id<br>User.find_signed(signed_id)<br>=&gt; [user record]</pre><p><strong>Advanced Usage:</strong></p><pre>signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset<br><br>User.find_signed signed_id <br>=&gt; nil # since the purpose does not match<br><br>travel 16.minutes<br>User.find_signed signed_id, purpose: :password_reset<br>=&gt; nil # since the signed id has expired<br><br>travel_back<br>User.find_signed signed_id, purpose: :password_reset <br>=&gt; [first user data]</pre><h3>References:</h3><p><a href="https://api.rubyonrails.org/classes/ActiveRecord/SignedId/ClassMethods.html#method-i-signed_id_verifier">ActiveRecord::SignedId::ClassMethods</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f592997f9191" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create login page with Firebase in Android | Kotlin]]></title>
            <link>https://medium.com/@rizadogukankosar/how-to-create-login-page-with-firebase-in-android-kotlin-491f90bc4f9?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/491f90bc4f9</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Sat, 05 Nov 2022 16:57:37 GMT</pubDate>
            <atom:updated>2022-11-05T16:57:37.698Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*LcWmOA7KJV6D631O9YsibA.png" /></figure><p>Hi everyone, today we create a login page with using Firebase and Kotlin.</p><ol><li>Create new empty activity and use Linear layout:</li></ol><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    tools:context=&quot;.LoginActivity&quot;<br>    android:orientation=&quot;vertical&quot;&gt;<br><br>&lt;/LinearLayout&gt;</pre><p>2. Gradient Background:</p><p>Drawable &gt; new &gt; Drawable Resource File</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*fv6e_iOaBEUKZmdI9kHS9w.png" /></figure><p>Now use this code:</p><p>gradient_background.xml</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;selector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;<br>    &lt;item&gt;<br>        &lt;shape&gt;<br>            &lt;gradient<br>                android:angle=&quot;90&quot;<br>                android:startColor=&quot;#071319&quot;<br>                android:endColor=&quot;#1381B2&quot;<br>                android:type=&quot;linear&quot; /&gt;<br>        &lt;/shape&gt;<br>    &lt;/item&gt;<br>&lt;/selector&gt;</pre><p>3. Button Style:</p><p>Drawable &gt; new &gt; Drawable Resource File</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*Y_rPCadzkuTpKQ2xIrA-8Q.png" /></figure><p>and use this code:</p><p>login_button_style.xml:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;shape xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:shape=&quot;rectangle&quot;&gt;<br>    &lt;corners android:radius=&quot;50dp&quot; /&gt;<br>    &lt;stroke android:width=&quot;3px&quot; android:color=&quot;#ffffff&quot; /&gt;<br>&lt;/shape&gt;</pre><p>4. Components:</p><p>Now add components in login view:</p><p>activity_login.xml:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;<br>    xmlns:tools=&quot;http://schemas.android.com/tools&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>    android:layout_height=&quot;match_parent&quot;<br>    tools:context=&quot;.LoginActivity&quot;<br>    android:background=&quot;@drawable/gradient_background&quot;<br>    android:orientation=&quot;vertical&quot;&gt;<br><br>    &lt;ImageView<br>        android:id=&quot;@+id/imageView&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;100dp&quot;<br>        android:layout_marginTop=&quot;32dp&quot;<br>        android:src=&quot;@drawable/logo&quot; /&gt;<br><br>    &lt;TextView<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/email&quot;<br>        android:textColor=&quot;@color/white&quot;<br>        android:textSize=&quot;12sp&quot;<br>        android:layout_marginTop=&quot;50dp&quot;<br>        android:layout_marginStart=&quot;35dp&quot;/&gt;<br>    &lt;EditText<br>        android:id=&quot;@+id/emailEditText&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;40dp&quot;<br>        android:backgroundTint=&quot;@color/white&quot;<br>        android:textColor=&quot;@color/text_gray&quot;<br>        android:layout_marginHorizontal=&quot;35dp&quot;<br>        android:layout_marginTop=&quot;15dp&quot;<br>        android:inputType=&quot;textEmailAddress&quot;/&gt;<br><br>    &lt;TextView<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:text=&quot;@string/password&quot;<br>        android:textColor=&quot;@color/white&quot;<br>        android:textSize=&quot;12sp&quot;<br>        android:layout_marginTop=&quot;30dp&quot;<br>        android:layout_marginStart=&quot;35dp&quot;/&gt;<br><br>    &lt;EditText<br>        android:id=&quot;@+id/passwordEditText&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;40dp&quot;<br>        android:backgroundTint=&quot;@color/white&quot;<br>        android:textColor=&quot;@color/text_gray&quot;<br>        android:layout_marginHorizontal=&quot;35dp&quot;<br>        android:layout_marginTop=&quot;15dp&quot;<br>        android:inputType=&quot;textPassword&quot;/&gt;<br><br>    &lt;androidx.appcompat.widget.AppCompatButton<br>        android:layout_width=&quot;150dp&quot;<br>        android:layout_height=&quot;40dp&quot;<br>        android:text=&quot;@string/login&quot;<br>        android:textColor=&quot;@color/white&quot;<br>        android:background=&quot;@drawable/login_button_style&quot;<br>        android:textSize=&quot;14sp&quot;<br>        android:textAllCaps=&quot;false&quot;<br>        android:layout_marginTop=&quot;25dp&quot;<br>        android:layout_gravity=&quot;center&quot;<br>        android:onClick=&quot;Login&quot;<br>        tools:ignore=&quot;OnClick&quot; /&gt;<br><br>&lt;/LinearLayout&gt;</pre><p>LoginActivity.kt</p><pre>package com.voilist.voilist.views.Authentications<br><br>import android.os.Bundle<br>import android.view.View<br>import android.widget.Toast<br>import androidx.appcompat.app.AppCompatActivity<br>import com.google.android.gms.tasks.OnCompleteListener<br>import com.google.firebase.auth.AuthResult<br>import com.google.firebase.auth.FirebaseAuth<br>import com.google.firebase.auth.FirebaseUser<br>import com.voilist.voilist.databinding.ActivityLoginBinding<br><br><br>class LoginActivity : AppCompatActivity() {<br>    private lateinit var binding: ActivityLoginBinding<br>    private lateinit var mAuth: FirebaseAuth<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        binding = ActivityLoginBinding.inflate(layoutInflater)<br>        setContentView(binding.root)<br>        mAuth = FirebaseAuth.getInstance()<br>    }<br><br>    fun Login(view: View) {<br>        val email = binding.emailEditText.text.toString().trim()<br>        val password = binding.passwordEditText.text.toString()<br>        mAuth.signInWithEmailAndPassword(email,password).addOnSuccessListener <strong>{<br>            </strong>Toast.makeText(this,&quot;Welcome&quot;,Toast.LENGTH_SHORT).show()<br>        <strong>}</strong>.addOnFailureListener <strong>{<br>            </strong>Toast.makeText(this,it.message,Toast.LENGTH_SHORT).show()<br>        <strong>}<br></strong><br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=491f90bc4f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make options menu in Android (JAVA)]]></title>
            <link>https://medium.com/@rizadogukankosar/how-to-make-options-menu-in-android-java-937f578ee88e?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/937f578ee88e</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 15:11:52 GMT</pubDate>
            <atom:updated>2022-02-25T15:14:52.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*6aZVbPko-qAgsiBl4_N4Eg.jpeg" /></figure><p><strong>1.Add menu dictionary:</strong></p><p>App &gt; Res</p><p>right click</p><p>new &gt; Android Resource Dictionary</p><p>Resource Type : menu</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*22FwYuplIwvGGs_E6GSsyg.png" /></figure><p><strong>2. Create menu.xml:</strong></p><p>App &gt; Res &gt; menu</p><p>right click</p><p>new &gt; Menu Resource File</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dths3B7G3QfP6IrjCv0Gxw.png" /></figure><p><strong>3. Add menu items:</strong></p><p>option_menu.xml:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;menu<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;<br><br>    &lt;item android:id=&quot;@+id/settings&quot; android:title=&quot;Settings&quot;/&gt;<br>    &lt;item android:id=&quot;@+id/logout&quot; android:title=&quot;Log out&quot;/&gt;<br>&lt;/menu&gt;</pre><p><strong>4. Put menu on Activity:</strong></p><p>Activity.java:</p><pre>@Override<br>public boolean onCreateOptionsMenu(Menu menu) {<br>    getMenuInflater().inflate(R.menu.<em>options_menu</em>,menu);<br>    return true;<br>}</pre><p><strong>5. Add item selected method:</strong></p><p>Activity.java:</p><pre>@Override<br>public boolean onOptionsItemSelected(MenuItem item) {<br>    switch (item.getItemId()){<br>        case R.id.<em>settings</em>:<br>     //if clicked settings<br>            Toast.<em>makeText</em>(getApplicationContext(), &quot;Settings&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>            break;<br>        case R.id.<em>logout</em>:<br>     // if clicked logout<br>            Toast.<em>makeText</em>(getApplicationContext(), &quot;Logout&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>            break;<br>    }<br><br>    return super.onOptionsItemSelected(item);<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=937f578ee88e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to show an alert message in Android(JAVA)]]></title>
            <link>https://medium.com/@rizadogukankosar/how-to-show-an-alert-message-in-android-java-71dad501f77?source=rss-483a96e54eb1------2</link>
            <guid isPermaLink="false">https://medium.com/p/71dad501f77</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android-apps]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Rıza Doğukan Koşar]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 14:53:51 GMT</pubDate>
            <atom:updated>2022-02-25T14:57:00.710Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*5oIEZ-dWKjzs6SG-E6RG3w.jpeg" /></figure><ol><li>Create dialog builder:</li></ol><pre>AlertDialog.Builder alert = new AlertDialog.Builder(this);</pre><p>2. Title and message:</p><pre>alert.setTitle(&quot;My Title&quot;);<br>alert.setMessage(&quot;The message in Alert&quot;);</pre><p>3. Buttons:</p><pre>alert.setPositiveButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {<br>    @Override<br>    public void onClick(DialogInterface dialog, int which) {<br>        Toast.<em>makeText</em>(getApplicationContext(), &quot;Pushed yes&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>});</pre><pre>alert.setNegativeButton(&quot;No&quot;, new DialogInterface.OnClickListener() {<br>    @Override<br>    public void onClick(DialogInterface dialog, int which) {<br>        Toast.<em>makeText</em>(getApplicationContext(), &quot;Pushed no&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>});</pre><p>4. Show dialog:</p><pre>alert.show();</pre><p>Full Code:</p><pre>AlertDialog.Builder alert = new AlertDialog.Builder(this);<br>alert.setTitle(&quot;My Title&quot;);<br>alert.setMessage(&quot;The message in Alert&quot;);<br>alert.setPositiveButton(&quot;Yes&quot;, new DialogInterface.OnClickListener() {<br>    @Override<br>    public void onClick(DialogInterface dialog, int which) {<br>        Toast.<em>makeText</em>(getApplicationContext(), &quot;Pushed yes&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>});<br>alert.setNegativeButton(&quot;No&quot;, new DialogInterface.OnClickListener() {<br>    @Override<br>    public void onClick(DialogInterface dialog, int which) {<br>        Toast.<em>makeText</em>(getApplicationContext(), &quot;Pushed no&quot;, Toast.<em>LENGTH_SHORT</em>).show();<br>    }<br>});<br>alert.show();</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71dad501f77" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>