Skip to content

Instantly share code, notes, and snippets.

@ignaciojonas
Created March 3, 2021 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ignaciojonas/35bcff5b7204c8201c7a575a334a5fe8 to your computer and use it in GitHub Desktop.
Save ignaciojonas/35bcff5b7204c8201c7a575a334a5fe8 to your computer and use it in GitHub Desktop.
def index
@styles = Style.all
@style = Style.new
end
def create
@style = Style.new(style_params)
respond_to do |format|
if @style.save
format.html { redirect_to styles_url, notice: "Style was successfully created." }
format.json { render :show, status: :created, location: @style }
else
format.turbo_stream { render turbo_stream: turbo_stream.replace(@style, partial: "styles/form", locals: { style: @style}) }
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @style.errors, status: :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment