class SignupForm
include ActiveModel::Model
include ActiveModel::Attributes
attribute :account_name, :string
attribute :email, :string
module Api
module V1
class PostsController < ApplicationController
def create
post = current_user.posts.build(post_params)
class Order < ApplicationRecord
has_many :line_items, dependent: :destroy, inverse_of: :order
accepts_nested_attributes_for :line_items,
reject_if: :all_blank,
allow_destroy: true
Rails.application.routes.draw do
resources :articles do
resources :comments, shallow: true, only: %i[index new create show edit update destroy]
end
root "articles#index"
class Order < ApplicationRecord
has_many :line_items, inverse_of: :order, dependent: :destroy
accepts_nested_attributes_for :line_items,
allow_destroy: true,
reject_if: ->(attrs) { attrs["product_id"].blank? && attrs["quantity"].blank? }
class Product < ApplicationRecord
scope :by_status, ->(status) {
status.present? ? where(status: status) : all
}
scope :in_category, ->(category_id) {
<%= form_with url: bulk_update_orders_path, method: :patch, data: { turbo_confirm: "Update selected orders?" } do %>
<div class="batch-toolbar">
<%= select_tag :status,
options_for_select(Order.statuses.keys.map { |s| [s.humanize, s] }),
prompt: "Set status to\u2026" %>
<%= submit_tag "Apply to selected", class: "btn" %>
class AddressForm
include ActiveModel::Model
include ActiveModel::Attributes
attribute :line1, :string
attribute :line2, :string