Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
In rails project, one common scenario is:
One form used to create or update an object can be routed from more than one page, when the object is created or updated, it should be redirected back to wherever it came from.
Rails redirect_back
doesn't work in this case because:
redirect_back
in create/update action will go back to new/edit form.redirect_back
.rails-source-path
can hanlde this by explicily specifying the entry actions and remember the
previous route in session
store, hence can be used later in the whole controller. Also a helper
method is providered so it can be used in view like back
or cancel
button.
Add this line to your application's Gemfile:
gem 'rails_source_path'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rails_source_path
class YourController < ApplicationController
rails_source_path_entry_actions :new, :edit
...
def create
if @object.create
redirect_to_source
else
...
end
end
def update
if @object.save
redirect_to_source
else
...
end
end
end
# in your view/partial
link_to 'Cancel', rails_source_path, class: 'button'
Both redirect_to_source
and rails_source_path
accept an optional argument which is the path when there is no previous route remembered.
def rails_source_path(default_path = root_path)
def redirect_to_source(default_path = root_path)
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that rails_source_path 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.