Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
simple_form-magic_submit
Advanced tools
A smart submit button extension for the Simple Form gem that:
For a newly created model object, typically in a new.html.haml
:
Add a cancel link:
When something goes wrong and the model fails validation:
And all this and a bit more with just a single line of code:
= f.button :magic_submit, cancel: root_path
Add this line to your application's Gemfile:
gem 'simple_form-magic_submit'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_form-magic_submit
In your view template add it allong the lines of:
= simple_form_for(resource) do |f|
= f.error_notification
.form-inputs
= f.input :email, autofocus: true
.form-actions
= f.button :magic_submit
The last one is this gem's magic.
To add a cancel link:
= simple_form_for(resource) do |f|
= f.error_notification
.form-inputs
= f.input :email, autofocus: true
.form-actions
= f.button :magic_submit, cancel: root_path
Replace root_path
with whatever path is relevant for your app.
The gem comes bundled with an English translation in en.yml:
en:
simple_form:
magic_submit:
default:
new:
submit: "Create a new %{model}"
retry: "Try creating once again"
disable_with: "Creating…"
edit:
submit: "Save changes"
retry: "Try saving once again"
disable_with: "Saving…"
cancel:
format: "%{submit_button} or %{cancel_link}"
cancel: "Cancel"
Simply copy the file to you config/locales
folder inside your Rails project if you want to change the default strings.
Say, for the title the keys will be looked up in the following order:
simple_form.magic_submit.namespace_name.controller_name.model_name.action.submit
simple_form.magic_submit.namespace_name.controller_name.action.submit
simple_form.magic_submit.default.action.submit
helpers.submit.action
Say, for a Admin::UsersController
and a Roles
model, the following lookups will be
made on the edit action:
simple_form.magic_submit.admin.users.roles.edit.submit
simple_form.magic_submit.admin.users.edit.submit
simple_form.magic_submit.default.edit.submit
helpers.submit.edit
Each lookup will have %{model}
interpolated to the name of the model.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Victor Nahuel Chaves (https://github.com/nahue) for adding support for model-less forms.
FAQs
Unknown package
We found that simple_form-magic_submit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.