- Mar 2022
-
github.com github.com
-
-
If you need to ensure migrations run in a certain order with regular db:migrate, set up Outrigger.ordered. It can be a hash or a proc that takes a tag; either way it needs to return a sortable value: Outrigger.ordered = { predeploy: -1, postdeploy: 1 } This will run predeploys, untagged migrations (implicitly 0), and then postdeploy migrations.
-
class PreDeployMigration < ActiveRecord::Migration tag :predeploy end
-
-
This is especially useful for zero downtime deploys to Production environments.
-
-
railsguides.net railsguides.net
-
The code will work without exception but it doesn’t set correct association, because the defined classes are under namespace AddStatusToUser. This is what happens in reality: role = AddStatusToUser::Role.create!(name: 'admin') AddStatusToUser::User.create!(nick: '@ka8725', role: role)
-
-
github.com github.com
-
If the gem purpose is still not clear please check out this blog post.
-
this gem promotes writing tests for data migrations providing a way allows to write code that migrates data in separate methods.
-
having the code migrates data separately covered by proper tests eliminates those pesky situations with outdated migrations or corrupted data.
-
-
-
-
If the users table is large, running this migration on a live Postgres 9 database will likely cause downtime. Safe PG Migrations hooks into Active Record so that the following gets executed instead: class AddAdminToUsers < ActiveRecord::Migration[5.2] # Do not wrap the migration in a transaction so that locks are held for a shorter time. disable_ddl_transaction! def change # Lower Postgres' lock timeout to avoid statement queueing. Acts like a seatbelt. execute "SET lock_timeout TO '5s'" # The lock_timeout duration is customizable. # Add the column without the default value and the not-null constraint. add_column :users, :admin, :boolean # Set the column's default value. change_column_default :users, :admin, false # Backfill the column in batches. User.in_batches.update_all(admin: false) # Add the not-null constraint. Beforehand, set a short statement timeout so that # Postgres does not spend too much time performing the full table scan to verify # the column contains no nulls. execute "SET statement_timeout TO '5s'" change_column_null :users, :admin, false end end
-
-
-
-
There are three keys to backfilling safely: batching, throttling, and running it outside a transaction. Use the Rails console or a separate migration with disable_ddl_transaction!.
-
Active Record creates a transaction around each migration, and backfilling in the same transaction that alters a table keeps the table locked for the duration of the backfill. class AddSomeColumnToUsers < ActiveRecord::Migration[7.0] def change add_column :users, :some_column, :text User.update_all some_column: "default_value" end end
-
-
-
github.com github.com
-
Can you check out whether the polkit permission is even queried by adding a rule /etc/polkit-1/rules.d/10-udisks.rules. polkit.addRule(function(action, subject) { var prefix = "org.freedesktop.udisks"; if (action.id.slice(0, prefix.length) == prefix) polkit.log(action.id); });
-
echo "TEMP /dev/sdb2 /home/key" >> /etc/crypttab
-
One of the DEBUG lines near the end of the udiskie output should contain a hint as to why the device was rejected by udiskie.
.
-
Let's investigate:
maintainer willing to help debut
-
udiskie-mount -v /dev/sdb2 gdbus call --system --dest org.freedesktop.UDisks2 --object-path /org/freedesktop/UDisks2/block_devices/sdb2 --method org.freedesktop.DBus.Properties.GetAll org.freedesktop.UDisks2.Block
.
Tags
Annotators
URL
-
-
open-source.braveclojure.com open-source.braveclojure.com
-
list of open-source projects
-
-
github.com github.com
-
-
No need to construct strings that then need to be deconstructed later.
-
And events are just data so can process, enrich, filter, aggregate, visualise the data with your own tools.
-
Because it is cheap to log events, you can freely log plenty.
.
-
Event logs are useful, but not as important as process flow (therefore preferable to drop events rather than crashing the process)
.
-
I believe we need the break free of these anachronistic designs and use event loggers, not message loggers
-
In any significant project I worked in the last 15 years, logging text messages resulted in a large amount of strings which was hard to make sense of, thus mostly ignored.
hard to make sense of, thus mostly ignored
-
µ/log's idea is to replace the "3 Pillars of Observability" with a more fundamental concept: "the event"
bold goal
-
Event-based data is easy to index, search, augment, aggregate and visualise therefore can easily replace traditional logs, metrics and traces.
-
-
github.com github.com
-
// Native const datePattern = /^(\d{2})-(\d{2})-(\d{4})$/; const [, month, day, year] = datePattern.exec('12-25-1995'); new Date(`${month}, ${day} ${year}`);
-
-
momentjs.com momentjs.com
-
Modern JavaScript environments will also implement the by ECMA-402 specification, which provides the Intl object
-
-
Using Date.parse, or new Date(<string>) has been problematic and implemented inconsistently in the past. The current specification defines parsing a variation of ISO 8601 strings, where date-only forms (like "2020-09-14") are parsed as UTC, instead of local time as they would be by ISO 8601.
-
not all modern implementations have implemented this specification correctly (e.g., Safari)
-
You Probably Don't Need Moment.js Anymore You don't (may not) need Moment.js
-
The Moment team has discussed these issues at length. We recognize that many existing projects may continue to use Moment, but we would like to discourage Moment from being used in new projects going forward. Instead, we would like to recommend alternatives that are excellent choices for use in modern applications today.
-
-
en.wikipedia.org en.wikipedia.org
-
The chip was developed as a result of the 1983 video game crash in North America, partially caused by an oversaturated market of console games due to lack of publishing control. Nintendo president Hiroshi Yamauchi said in 1986, "Atari collapsed because they gave too much freedom to third-party developers and the market was swamped with rubbish games."[6] By requiring the presence of the 10NES in a game cartridge, Nintendo prevented third-party developers from producing games without Nintendo's approval, and provided the company with licensing fees
Tags
Annotators
URL
-
-
stackoverflow.com stackoverflow.com
-
There's an open suggestion at microsoft/TypeScript#13347 to introduce a compiler flag or some other mechanism to more strictly enforce readonly, but it's been around for a long time and it's not clear whether or not this will ever happen.
may not ever happen...
-
-
stackoverflow.com stackoverflow.com
-
The cleanest is to give up on readonly properties and instead use some kind of mapping that turns an object into something you really can only read from, via something like getter functions.
-
-
developer.mozilla.org developer.mozilla.org
-
The HTMLLabelElement.htmlFor property reflects the value of the for content property.
-
-
code.visualstudio.com code.visualstudio.com
-
Note that this is a breaking API change in the libraries (more information in the README.md). It does not affect the backwards compatibility of the protocol itself.
annotation meta: may need new tag: backwards compatibility of the protocol backwards compatibility for [libraries that use [it?]]
-
ambiguous and invisible Unicode characters
'е' != 'e'
-
-
www.facebook.com www.facebook.com
Tags
Annotators
URL
-
-
www.stephenchu.com www.stephenchu.com
-
Now if I may ask, if my formatting is happening in multiple places, is this domain logic? I tend to say it is.
.
-
One of the toughest decisions that a developer always has to make is to distinguish between domain logic and non-domain logic.
.
-
-
developer.squareup.com developer.squareup.com
-
store.steampowered.com store.steampowered.com
-
War im Weihnachtskalender bei Chip. Habe selten so ein Schwachsinn gesehen. Ich weiß nicht was die Entwickler sich dabei denken. Man läuft einfach nur hin und her. Auch wenn es kostenlos war, die Zeit hätte ich mir sparen können.
-
-
whiteestate.org whiteestate.org
-
Some workers need to give up the slow methods of work which prevail, and to learn to be prompt. Promptness is necessary, as well as diligence. If we wish to accomplish the work according to the will of God, it must be done in an expeditious manner, but not without thought and care.
.
-
There should be regular hours for rising, for family worship, for meals, and for work. And it is a religious duty ... to maintain this by precept ... by a firm example. Many squander the most precious hours of the morning hoping that they can terminate the work thus neglected during the hours which should be devoted to sleep. Godliness, health, success, everything suffers from this lack of true religious system....
.
-
The work of God must not be done by fits and starts. It will not be placed on vantage ground by following a sudden impulse. On the contrary, it is positively necessary to follow the good work patiently, day by day, progressing in our ways and methods. One should get up at a regular hour. If during the day the work is neglected, and the following night is spent in making up for lost time, the morrow and following day will show, as a result, a wearied brain and a general fatigue which constitute positive violations of the law of life and health.
.
-
God has entrusted His sacred work to human beings, and He asks that they shall do it carefully.... They press too many things into their life, postpone until tomorrow that which demands their attention today, and much time is lost in painfully picking up the lost stitches. Men and women can reach a higher degree of usefulness than to carry with them through life an unsettled state of mind. They can improve the defective traits of their character contracted in their younger years. Like Paul, they can labor to reach a much higher degree of perfection.
.
-
-
store.steampowered.com store.steampowered.com
-
4. it will say winenr no matter what, but the color of the winner text will simblize who won. all the dots will also turn that color.
.
-
-
www.imdb.com www.imdb.com
-
The majority of self-help material is little more than inconsequential banal garbage that provides light titillation to its gullible consumers. The Secret, however, is far more insidious. The implicit messages are actually quite reckless and extremely inappropriate. At one point, one of the 'experts' claims that being involved in a car crash is merely a result of your thought patterns and it could have been avoided with more positive thinking. Seriously, he actually said that. How does an incest survivor process this kind of information? Given the type of vulnerable people that will be drawn to a documentary like this, it is actually pretty disgusting to hear such idiotic comments.
.
-
At times it is actually quite hard to discern whether this is just satire, but sadly it is not.
.
-
One of the single worst pieces of television ever made. Every piece of human garbage associated with this repulsive bilge deserves to be publicly shamed.
.
-
-
github.com github.com
-
Gutentag::ActiveRecord.call self
first time I've seen this API in Ruby
Most would just do include Gutentag::ActiveRecord. or acts_as_taggable
-
-
stackoverflow.com stackoverflow.com
-
You could also check if Time.now > @user.last_active+10.minutes before updating to make sure that you aren't constantly writing to the db
efficiency compromise
-
-
discord.com discord.com
-
or the endangerment of public health
unless preventing people from freely discussing/sharing about what information/treatments they believe is effective/helpful for public health ... is actually more harmful to public health than allowing them to freely post.
Tags
Annotators
URL
-
-
dba.stackexchange.com dba.stackexchange.com
-
ARRAY( SELECT DISTINCT ... FROM unnest(arr) )
-
And that can all can be written with CROSS JOIN LATERAL which is much cleaner, SELECT ARRAY( SELECT DISTINCT e FROM ( VALUES ('foo', 'bar', 'foo', 'baz' ) ) AS t(a,b,c,d) CROSS JOIN LATERAL unnest(ARRAY[a,b,c,d]) AS a(e) -- ORDER BY e; -- if you want it sorted );
-
-
riseup.net riseup.net
-
share.riseup.net — file upload (pastebin and imagebin).
-
- Feb 2022
-
ruby-doc.org ruby-doc.org
-
-
There are two pairs of methods for sending/receiving messages: Object#send and ::receive for when the sender knows the receiver (push); Ractor.yield and Ractor#take for when the receiver knows the sender (pull);
-
-
www.instructables.com www.instructables.com
-
When i started using body wash I hit the jackpot. I use a 3 to 1 ratio of water to body wash and get fantastic results with an occasional clog
.
-
it kinda works, but obviously, never as good as the original foaming soap. The reason for that is, the foaming soap has a slightly different formula than regular soap. Specifically, it has more foaming ingredients (like sodium lauryl sulfate / sodium laureth sulfate) and less actual "soap".
.
-
The sad part of it all is that the manufacturers have found yet another way to rip off the consumer. They put one fourth the amount of soap in three fourths H20, change the dispenser slightly and then charge 4 times as much for the finished product. You do the math,
.
-
-
www.jacobsen.no www.jacobsen.no
-
Hence an email address/mailbox/addr-spec is "local-part@domain"; "local-part" is composed of one or more of 'word' and periods; "word" can be an "atom" which can include anything except "specials", control characters or blank/space; and specials (the *only* printable ASCII characters [other than space, if you call space "printable"] *excluded* from being a valid "local-part") are: ()<>@,;:\".[] Therefore by the official standard for email on the internet, the plus sign is as much a legal character in the local-part of an email address as "a" or "_" or "-" or most any other symbol you see on the main part of a standard keyboard.
-
There's a common design flaw on many many websites that require an email address to register; most recently I came across this bug on CNet's download.com site: for some reason they don't accept me when I try to register an email address containing a "+", and they then send me back saying my address is invalid. It isn't!
-
"+" is a completely valid character in an email address; as defined by the internet messaging standard published in 1982(!) RFC 822 (page 8 & 9)... Any website claiming anything else is wrong by definition, plus they are prohibiting me and many fellow anti-spam activists from tracking where inbound spam comes from:
-
-
people.cs.rutgers.edu people.cs.rutgers.edu
-
Screening is a useful way of avoiding spam and/or other unwanted correspondence.
-
Filing is the simplest application to take advantage of plus signs.
-
The "+tag" portion of the email address can then be used both for filing mail and for screening it.
-
-
github.com github.com
-
The current behaviour is definitely broken (at least in my mind). I don't think I'd consider it a feature just because it's been around a while.
-
Given that 5.2 and 6.0 now have this current (broken?) behavior, I wonder if this behavior will now be considered as breaking change.
-
we often work hard to make symbols and strings interchangeable in contexts where it makes sense
-
-
medium.com medium.com
-
-
lateral (select pledged / fx_rate as pledged_usd) pu, lateral (select pledged_usd / backers_count as avg_pledge_usd) apu, lateral (select goal / fx_rate as goal_usd) gu, lateral (select goal_usd - pledged_usd as usd_from_goal) ufg, lateral (select (deadline - launched_at)/86400.00 as duration) dr
-
-
sunfox.org sunfox.org
-
Comment[:article_id].in(Arel.sql(articles_sql))
-
Query values including NULLs Because .where.not can be counter-intuitive regarding NULL values, you can use is_distinct_from to include them. User.where(User[:active].is_distinct_from(true))
-
User.order(User[:email].desc.nulls_last)
-
User.order( Arel::Nodes::Case .new(User[:role]) .when("admin").then(1) .when("editor").then(2) )
-
User.distinct.pluck(User[:created_at].extract("year"))
-
space = Arel.sql("' '") User.pluck(User[:first_name].concat(space).concat(User[:last_name]))
-
User.where(User[:email].matches("%@example.org")) # => SELECT "users".* FROM "users" WHERE "users"."email" ILIKE '%@example.org'
-
User.where(User[:email].lower.eq(email.downcase)) # => SELECT "users".* FROM "users" WHERE LOWER("users"."email") = 'user@example.org'
-
class ApplicationRecord < ActiveRecord::Base def self.[](attribute) arel_table[attribute] end end
-
-
itectec.com itectec.com
-
It's safe to use CROSS JOIN LATERAL (or just , LATERAL) here, because the array constructor always returns a row. Else, if a lateral subquery could come up empty (no row), you would use LEFT JOIN LATERAL (...) ON true to avoid losing rows.
.
-
-
www.postgresql.org www.postgresql.org
-
Although COALESCE, GREATEST, and LEAST are syntactically similar to functions, they are not ordinary functions
-
-
stackoverflow.com stackoverflow.com
-
You can use to_char to convert the timestamp using appropriate format mask: COALESCE(to_char(timestamp_type, 'YYYY-MM-DD'), varchar_col)
-
But it's MUCH better to not rely on datestyle settings for converting date-times to/from text.
-
-
underpassapp.com underpassapp.com
-
underpassapp.com underpassapp.com
-
StopTheMadness is a web browser extension that stops web sites from making your browser harder to use
-
"The good news is that you can wrest control of your browser back from these malicious, control-freak sites."
-
unfortunately only iOS and Mac
see instead: - https://addons.mozilla.org/en-US/firefox/addon/enable-selection/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search
-
-
-
Dispatch a custom event. This differs from Svelte's component event system, because these events require a DOM element as a target, can bubble (and do by default), and are cancelable with event.preventDefault(). All SMUI events are dispatched with this instead of Svelte's createEventDispatcher.
-
In addition, a component that uses Svelte's built in event forwarding system cannot allow event listeners on the "capture" phase of the event lifecycle. It also cannot allow events to be cancelable with the browser's built in preventDefault function.
-
This is especially useful for UI library components, as it is generally unknown which events will be required from them for all desired use cases. For example, if a Button component only forwards a click event, then no use case that requires the mouseover or the keypress event can be used with it.
-
-
naturalselections.substack.com naturalselections.substack.com
-
-
This thing has struck a nerve here. Literally overnight millions of people are talking about real things again. But in such an abrupt way, it's odd, like they were suddenly turned on after having been flash frozen for the last two years.
.
-
-
support.google.com support.google.com
-
I want to filter emails to exclude starred message threads. Even a simple "-is:starred" or "-has:yellow-star" does not work.
limitation
-
-
standforhealthfreedom.com standforhealthfreedom.com
-
unix.stackexchange.com unix.stackexchange.com
-
dmsetup remove /dev/dm-5
.
-
udisksctl unlock -b /dev/sdg1
.
-
-
steamcommunity.com steamcommunity.com
-
blog.saeloun.com blog.saeloun.com
-
class Note < ApplicationRecord delegated_type :authorable, types: %w[ Customer Employee ] end
-
-
Checkout this PR to know more about this feature.
typo
-
-
github.com github.com
-
-
The existence of polymorphic associations does not allow the database to enforce referential integrity, however, because no foreign keys can be defined.
-
Good point. In my example, cardinalities would be fundamentally different: an Entry could have_many :messages and have_many :comments. In the original example, a Message could have_many :entries, etc. In either case, there's no way to enforce the cardinalities at the database level (not that I'm aware of).
-
@entry = Entry.create! entryable: Spot.new(params.require(:spot).permit(:address)) redirect_to @entry # Redirects to e.g. /spots/47, with 47 being the newly created Entry id.
-
Delegated types newly introduced here looks like a Class Table Inheritance (CTI).
-
I did a spike to come up with a PoC for introducing this into the codebase of a product that I'm working on (matteeyah/respondo#225) by monkey-patching ActiveRecord with delegated types. It's amazing how can a small code change in ActiveRecord facilitate a big change in the domain model.
-
I just thought that if there was any time to improve the naming it would be now, before rolling it out to thousands of devs/projects. I don't think of that as bikeshedding, personally.
-
I think I might inadvertently have shared plans for a bike shed and opened the floor to which color it should be painted. My sincerest apologies
-
That was my initial reaction too. I think because we are used to talking about delegating behavior, whereas this is delegating subtyping. Or in other words, delegating the ability to be extended with specialized behavior.
we're used to "delegating" meaning...
-
Is the name "delegated type" up for review? I don't see any delegation happening in the code. It looks more like a "subtype", or "secondary type", or something like that.
-
From the text as it is currently written, though, it is not entirely clear what the advantage would be of this new technique vs. using plain composition.
That's not clear to me either
Tags
- easier to figure out now than later after people are using it
- relational database design
- naming: the importance of good names
- delegation (programming)
- Rails
- referential integrity
- polymorphism
- I agree
- ActiveRecord: associations: delegated_type
- bikeshedding
- annotation meta: may need new tag
- new feature
Annotators
URL
-
-
martinfowler.com martinfowler.com
-
A very visible aspect of the object-relational mismatch is the fact that relational databases don't support inheritance. You want database structures that map clearly to the objects and allow links anywhere in the inheritance structure. Class Table Inheritance supports this by using one database table per class in the inheritance structure.
-
-
github.com github.com
Tags
Annotators
URL
-
-
github.com github.com
-
Another strategy is reinforcement learning (aka. constraint learning), as used in some AI systems.
-
has the operator return its first defined argument, then pass over the next defined one in case of a dead-end, in a depth-first selection algorithm.
-
The evaluation may result in the discovery of dead ends, in which case it must "switch" to a previous branching point and start over with a different alternative.
-
They allow for writing nondeterministic programs which contain various alternatives for the program flow.
-
Ambiguous functions
-
-
You may want to jump straight to the Examples section if formal stuff annoys you.
formal stuff annoys you
prefer practical vs. prefer theoretical/academic
-
A continuation is like a savepoint, representing "what's left to run" at a given time.
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
I tested it, and it indeed works, but I don't want to depend on a to-be-removed feature.
-
I am using them in a real life application. I am calculating the available tables for a full calendar with many time slots and with respect to many configurable business rules for restaurants. Using callcc this feature got blazingly fast and very nicely readable. Also we use it to optimise table arrangements with respect to complex restaurant business rules (even something like: Guest A doesn't like to sit near Guest B). Please just have a look at these resources: https://github.com/chikamichi/amb/tree/master/examples http://web.archive.org/web/20151116124853/http://liufengyun.chaos-lab.com/prog/2013/10/23/continuation-in-ruby.html Please help me to keep Guest A away from Guest B. Bad things might happen.
-
"Context" manipulation is one of big topic and there are many related terminologies (academic, language/implementation specific, promotion terminologies). In fact, there is confusing. In few minutes I remember the following related words and it is good CS exam to describe each :p Thread (Ruby) Green thread (CS terminology) Native thread (CS terminology) Non-preemptive thread (CS terminology) Preemptive thread (CS terminology) Fiber (Ruby/using resume/yield) Fiber (Ruby/using transfer) Fiber (Win32API) Generator (Python/JavaScript) Generator (Ruby) Continuation (CS terminology/Ruby, Scheme, ...) Partial continuation (CS terminology/ functional lang.) Exception handling (many languages) Coroutine (CS terminology/ALGOL) Semi-coroutine (CS terminology) Process (Unix/Ruby) Process (Erlang/Elixir) setjmp/longjmp (C) makecontext/swapcontext (POSIX) Task (...)
-
Using callcc this feature got blazingly fast and very nicely readable.
Tags
- context
- Ruby
- continuations
- what is the difference/distinction?
- control (programming)
- subtle distinction
- deprecated
- computer science
- deprecated with no replacement
- ruby: continuations
- ruby: fibers
- programming: fibers
- programming languages: learning/understanding the subtleties
- readability
- nuance
- control flow
Annotators
URL
-
-
ruby-doc.com ruby-doc.com
-
This (somewhat contrived) example allows the inner loop to abandon processing early: callcc {|cont| for i in 0..4 print "\n#{i}: " for j in i*5...(i+1)*5 cont.call() if j == 17 printf "%3d", j end end }
-
-
www.yld.io www.yld.io
-
For example, did you known React has nothing to do with reactive programming?
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
-
Ruby should not completely ignore blocks. const_set :Example, Class.new do p "Hello, world" end # Doesn't print anything, generate any warning nor error. To minimize any impact, Ruby should issue a warning, and in future version could even raise an error. Even unused variables provide warnings in verbose mode, and they have their use. I can't think of a case where passing a block to a builtin method that doesn't accept a block is not a programming error though.
But since it can't be fixed generally, then just add a check in each core method that doesn't accept block, update its def to include a check.
Where I've been bitten by this was some Enumerable method that I assumed took a block. I think it was
first { cond }
, and I assumed it worked the same asdetect { cond }
-
The remaining problem should be how to declare Ruby-define methods to be 'non-block taking'. Under the current language spec, absence of '& argument' may or may not mean the method would take a block.
-
-
thoughtbot.com thoughtbot.com
-
This solution can hide a bad user experience. We’re not making any DOM changes on AJAX success, meaning Capybara can’t automatically detect when the AJAX completes. If Capybara can’t see it, neither can our users. Depending on your application, this might be OK.
.
-
-
guides.rubyonrails.org guides.rubyonrails.org
-
As of Rails 7.0+, Active Record has an option for handling associations that would perform a join across multiple databases.
impressive
-
-
guides.rubyonrails.org guides.rubyonrails.org
-
You can also use silence_redefinition_of_method if you need to define the replacement method yourself (because you're using delegate, for example).
-
-
guides.rubyonrails.org guides.rubyonrails.org
-
You need to balance several factors: the need for new features, the increasing difficulty of finding support for old code, and your available time and skills, to name a few.
-
-
bugs.ruby-lang.org bugs.ruby-lang.org
-
I am open to discussion but I don't want to jump on the conclusion.
-
The biggest reason is that we still have several options, so I didn't want to restrict the future possibility.
-
Shouldn't the #descendants method be the reverse of #ancestors?
-
-
api.rubyonrails.org api.rubyonrails.org
-
stackoverflow.com stackoverflow.com
-
personally, i think this is useful when you have objects which are not stored in database, as shown in the database, e.g. temperature, gps location, balance, etc. You might ask then why those are not stored in the database? In the database we only store a value, but if we want to attach useful, relevant methods to that value,
-
-
github.com github.com
-
composed_of attr, :class_name => 'AddressableRecord::Address', :converter => :convert, :allow_nil => true,
-
-
en.wikipedia.org en.wikipedia.org
-
In computer science, a value object is a small object that represents a simple entity whose equality is not based on identity: i.e. two value objects are equal when they have the same value, not necessarily being the same object.
Tags
Annotators
URL
-
-
github.com github.com
-
There is nothing stopping you from creating store objects which scrapes XE for the current rates or just returns rand(2):
-
-
github.com github.com
-
For example the german city munich in german München .. both save a city-model with a name translated all app-locales.
doesn't seem all that useful if that's all it does
most place names would be the same in any language
-
-
-
belongs_to :city
-
-
github.com github.com
-
belongs_to :zipcode
-
-
github.com github.com
-
-
Country State (belongs to country) City (belongs to State) Neighborhood (belongs to city)
-
Address (Belongs to Neighborhood and City, because neighborhood is not required)
-
-
github.com github.com
-
biggs is a small ruby gem/rails plugin for formatting postal addresses from over 60 countries.
-
-
-
-
By default the wizard will render a view with the same name as the step. So for our controller AfterSignupController with a view path of /views/after_signup/ if call the :confirm_password step, our wizard will render /views/after_signup/confirm_password.html.erb
-
To send someone to the first step in this wizard we can direct them to after_signup_path(:confirm_password)
-
steps :confirm_password, :confirm_profile, :find_friends
-
Note that render_wizard does attempt to save the passed object. This means that in the above example, the object will be saved twice. This will cause any callbacks to run twice also. If this is undesirable for your use case, then calling assign_attributes (which does not save the object) instead of update might work better.
acceptable
-
-
-
Notice: Another method for partial validations, which might be considered more flexible by some users (allowing for easy validation testing inside model tests), was described by Josh McArthur here.
I liked the linked-to solution
-
The best way to build an object incrementally with validations is to save the state of our product in the database and use conditional validation. To do this we're going to add a status field to our Product class.
.
-
-
people want to have an object, lets call it a Product that they want to create in several different steps
-
-
www.joshmcarthur.com www.joshmcarthur.com
-
-
This action will work a little differently from a normal create action that you might be used to, as it doesn’t strictly need a new action - we won’t be saving this Pet model with any data - just putting it in the database so that our StepsController can access that.
-
Remember, our wizard controller is responsible for showing and updating steps, but our top-level controller is still responsible for managing our Pet models.
-
-
github.com github.com
-
and calls .unarchived and .archived appropriately when passed an ActiveRecord relation.
-
acts_as_tokened Quickly adds rails 5 has_secure_token to your model, along with some Post.find() enhancements to work with tokens instead of IDs.
-
include Effective::CrudController
-
# All queries and objects will be built with this scope resource_scope -> { current_user.posts } # Similar to above, with block syntax resource_scope do Post.active.where(user: current_user) end
-
Loads an appropriate @posts or @post type instance variable.
-
Replaces your Rails controllers, views and forms with meta programming. Considers routes.rb, ability.rb, current_user and does the right thing.
-
The goal of this gem is to reduce the amount of code that needs to be written when developing a ruby on rails website.
Tags
- alternative to mainstream way
- reduce the amount of boilerplate/duplication
- rails
- ActiveRecord: default scopes
- similar to:
- convention over configuration
- metaprogramming
- convention
- inherited_resources (Rails)
- ambitious goal
- ActiveRecord extensions
- MVC (model–view–controller)
- ActiveRecord: archiving
Annotators
URL
-
-
github.com github.com
-
enumerate_by :alpha_2_code
-
-
github.com github.com
-
Note that this is a reference implementation and, most likely, should be modified for your own usage.
-
-
github.com github.com
-
[:state, :zip]
presumably this groups them together more indivisibly, perhaps so they'll show up as a single line, for example?
-
-
www.ruby-toolbox.com www.ruby-toolbox.com
-
www.codeandeffect.com www.codeandeffect.com
-
-
github.com github.com
-
alias_method :normalize_whitespace_with_warning, :normalize_whitespace def normalize_whitespace(*args) silence_warnings do normalize_whitespace_with_warning(*args) end end
suppress warnings
-
-
thoughtbot.com thoughtbot.com
-
Since factory_bot_rails automatically loads factory definitions as your application loads, writing a definition like this would cause another Daniel to get added to your database every time you start the server or open a console. I like Daniels and all, but there is a limit.
-
-
github.com github.com
-
As a workaround, you can use setters in every affected reactive block instead of direct assignment. let localForm = {}; const setLocalForm = (data) => { localForm = data; }; $: setLocalForm({...$formData});
Tags
Annotators
URL
-
-
github.com github.com
-
Even though not all code smells indicate real problems (think fluent interfaces)
-
-
stackoverflow.com stackoverflow.com
-
At this point I would call into question the job of Event to both be responsible for managing what gets charged and how something should be charged. I would probably investigate moving those to external service classes to keep charging responsibilities out of a simple event object.
-
-
stackoverflow.com stackoverflow.com
-
however, I prefer to take it as an indication that a pretty smart group of people didn't think there was a particularly strong reason to use a different term.
seems reasonable
-
Unfortunately, I think a lot of the answers here are perpetuating or advancing the idea that there's some complex, meaningful difference. Really - there isn't all that much to it, just different words for the same thing.
-