# app/controllers/post/tags_controller.rb
class Post::TagsController < ApplicationController
def new
@tag = Tag.new
end
def create
@tag = Tag.new(tag_params)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001* ENV.fetch("NODE_VERSION") do | |
irb(main):002* `node --version` | |
irb(main):003* rescue | |
irb(main):004* "1.2.3" | |
irb(main):005> end | |
=> "1.2.3" | |
irb(main):006> exit | |
~/Desktop took 7s | |
❯ rails new node_demo \ |
# app/controllers/secret_messages_controller.rb
class SecretMessagesController < ApplicationController
def create
@secret_message_form = SecretMessageForm.new(secret_message_form_params)
if @secret_message_form.valid?
encrypted_content = encrypt_content(
seed_phrase: params[:secret_message_form][:seed_phrase],
password: params[:secret_message_form][:password],
hash_one = { "name" => "Steve"}
# => {"name"=>"Steve"}
hash_two = { name: "Steve"}
# => {:name=>"Steve"}
hash_one == hash_two
# => false
hash_one.with_indifferent_access == hash_two.with_indifferent_access
# => true
Testing a generator in a Rails engine can result in unwanted modifications of files in the test/dummy
directory.
# lib/generators/my_engine/install_generator.rb
module MyEngine
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
Sometimes there are cases when an actual human needs to intervene during edge cases.
# app/lib/manual_intervention_error.rb
class ManualInterventionError < StandardError
def initialize(message = "An error occured that needs to be addressed manually")
super
end
NewerOlder