Skip to content

ArgumentError when following readme for Rails #28

@drewhoffer

Description

@drewhoffer

Versions:

class_variants: 1.0
rails: 8.0.1
ruby-3.3.4

Hey I'm trying to get running with a Rails 8 app with this gem.

I've installed and created a StyleHelper taken from the getting started:

module StyleHelper
  def button_classes(classes, **args)
    class_variants(
      base: "inline-flex items-center rounded border border-transparent font-medium text-white hover:text-white shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2",
      variants: {
        size: {
          sm: "px-2.5 py-1.5 text-xs",
          md: "px-3 py-2 text-sm",
          lg: "px-4 py-2 text-sm",
          xl: "px-4 py-2 text-base"
        },
        color: {
          indigo: "bg-indigo-600 hover:bg-indigo-700 focus:ring-indigo-500",
          red: "bg-red-600 hover:bg-red-700 focus:ring-red-500",
          blue: "bg-blue-600 hover:bg-blue-700 focus:ring-blue-500"
        }
      },
      defaults: {
        size: :md,
        color: :indigo
      }
    )
  end
end

But I am now getting an error in my view from:

<%= form.submit "Sign up", class: button_classes.render(size: :sm) %>

The error im getting is:

Image

Figured I would post here in case of newcomers running into same issue.

Any help would be appreciated, I will post the steps I took to resolve this if I do tonight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions