mirror of
https://github.com/tildeverse/lobsters
synced 2024-06-24 17:27:04 +00:00
rubocop: Rails/Validation, 223
This commit is contained in:
parent
62545012b8
commit
b8ad1c5c91
|
@ -2,7 +2,7 @@ class HiddenStory < ApplicationRecord
|
|||
belongs_to :user
|
||||
belongs_to :story
|
||||
|
||||
validates_presence_of :user_id, :story_id
|
||||
validates :user_id, :story_id, presence: true
|
||||
|
||||
def self.hide_story_for_user(story_id, user_id)
|
||||
HiddenStory.where(:user_id => user_id, :story_id =>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class Keystore < ApplicationRecord
|
||||
self.primary_key = "key"
|
||||
|
||||
validates_presence_of :key
|
||||
validates :key, presence: true
|
||||
|
||||
def self.get(key)
|
||||
self.find_by(:key => key)
|
||||
|
|
|
@ -8,12 +8,12 @@ class Message < ApplicationRecord
|
|||
:foreign_key => "author_user_id",
|
||||
:inverse_of => :sent_messages
|
||||
|
||||
validates_presence_of :recipient
|
||||
validates :recipient, presence: true
|
||||
|
||||
attr_reader :recipient_username
|
||||
|
||||
validates_length_of :subject, :in => 1..100
|
||||
validates_length_of :body, :maximum => (64 * 1024)
|
||||
validates :subject, length: { :in => 1..100 }
|
||||
validates :body, length: { :maximum => (64 * 1024) }
|
||||
|
||||
scope :unread, -> { where(:has_been_read => false, :deleted_by_recipient => false) }
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ class SavedStory < ApplicationRecord
|
|||
belongs_to :user
|
||||
belongs_to :story
|
||||
|
||||
validates_presence_of :user_id, :story_id
|
||||
validates :user_id, :story_id, presence: true
|
||||
|
||||
def self.save_story_for_user(story_id, user_id)
|
||||
SavedStory.where(:user_id => user_id, :story_id =>
|
||||
|
|
|
@ -7,7 +7,7 @@ class Search
|
|||
attr_accessor :q, :order
|
||||
attr_accessor :results, :page, :total_results, :per_page
|
||||
|
||||
validates_length_of :q, :minimum => 2
|
||||
validates :q, length: { :minimum => 2 }
|
||||
|
||||
def initialize
|
||||
@q = ""
|
||||
|
|
|
@ -25,10 +25,10 @@ class Story < ApplicationRecord
|
|||
|
||||
scope :unmerged, -> { where(:merged_story_id => nil) }
|
||||
|
||||
validates_length_of :title, :in => 3..150
|
||||
validates_length_of :description, :maximum => (64 * 1024)
|
||||
validates_length_of :url, :maximum => 250, :allow_nil => true
|
||||
validates_presence_of :user_id
|
||||
validates :title, length: { :in => 3..150 }
|
||||
validates :description, length: { :maximum => (64 * 1024) }
|
||||
validates :url, length: { :maximum => 250, :allow_nil => true }
|
||||
validates :user_id, presence: true
|
||||
|
||||
validates_each :merged_story_id do |record, _attr, value|
|
||||
if value.to_i == record.id
|
||||
|
|
Loading…
Reference in New Issue
Block a user